yes, qt can open a bottle if you make a serial port device with a robot arm, program a nice gui with image recognition through a webcam, that finds the bottle and opens it...
shouldn't take more than a few hours I guess 
For a TabWidget that can add/remove pages, but still remember them, use a stackedwidget where you keep the widgets always, and use a TabBar with indexing, where you update the index when you add/remove tabs.
I have not tested the below code, as it's a rewrite of something I did a few months ago, but you will get a hint on where to start off.
header:
{
Q_OBJECT
public:
};
class QMyCustomTabBar
: public QTabBar{
Q_OBJECT
public:
QList <unsigned
short int> TabPage;
public slots:
PageToView(int index);
RemoveTabWithNo(unsigned short int stackedpagenumber);
InsertTabWithNo
(unsigned short int stackedpagenumber,
const QString &TabString
);
signals:
SendPageToView(unsigned int index);
};
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent);
};
class QMyCustomTabBar : public QTabBar
{
Q_OBJECT
public:
QMyCustomTabBar(QWidget *parent);
QList <unsigned short int> TabPage;
public slots:
PageToView(int index);
RemoveTabWithNo(unsigned short int stackedpagenumber);
InsertTabWithNo(unsigned short int stackedpagenumber, const QString &TabString);
signals:
SendPageToView(unsigned int index);
};
To copy to clipboard, switch view to plain text mode
source:
{
myStacked->addWidget(widget1);
myStacked->addWidget(widget2);
myStacked->addWidget(widget3);
QMyCustomTabBar *myCustomTabBar = new QMyCustomTabBar(this);
connect (myCustomTabBar, SIGNAL(SendPageToView(int)), myStacked, SLOT(setCurrentIndex(int)));
// then use RemoveTabWithNo and InsertTabWithNo to remove/insert.
// subclass checkbox'es or add slots for checkbox'es if you need those to enable disable
}
{
connect (this, SIGNAL(currentChanged(int)), this, SLOT(PageToView(int)));
}
void QMyCustomTabBar::PageToView(int index)
{
if (index < this->TabPage.count())
{
emit(SendPageToView(TabPage[index]));
}
}
void QMyCustomTabBar::RemoveTabWithNo(unsigned short int stackedpagenumber)
{
for (int i = 0;i < this->TabPage.count(); i++)
{
if (TabPage[i] == stackedpagenumber)
{
TabPage.removeAt(i);
this->removeTab(i);
return;
}
}
}
void QMyCustomTabBar
::InsertTabWithNo(unsigned short int stackedpagenumber,
const QString &TabString
) {
// see if we have a tab we need to insert it before...
for (int i = 0;i < this->TabPage.count(); i++)
{
if (TabPage[i] > stackedpagenumber)
{
TabPage.insert(i, stackedpagenumber);
this->insertTab(i, TabString);
return;
}
}
// if not, we should insert at the end
this->TabPage.append(stackedpagenumber);
this->addTab(TabString);
}
MyWidget::MyWidget(QWidget *parent) : QWidget (parent)
{
QStackedWidget *myStacked = new QStackedWidget(this);
myStacked->addWidget(widget1);
myStacked->addWidget(widget2);
myStacked->addWidget(widget3);
QMyCustomTabBar *myCustomTabBar = new QMyCustomTabBar(this);
connect (myCustomTabBar, SIGNAL(SendPageToView(int)), myStacked, SLOT(setCurrentIndex(int)));
// then use RemoveTabWithNo and InsertTabWithNo to remove/insert.
// subclass checkbox'es or add slots for checkbox'es if you need those to enable disable
}
QMyCustomTabBar::QMyCustomTabBar(QWidget *parent) : QTabBar (parent)
{
connect (this, SIGNAL(currentChanged(int)), this, SLOT(PageToView(int)));
}
void QMyCustomTabBar::PageToView(int index)
{
if (index < this->TabPage.count())
{
emit(SendPageToView(TabPage[index]));
}
}
void QMyCustomTabBar::RemoveTabWithNo(unsigned short int stackedpagenumber)
{
for (int i = 0;i < this->TabPage.count(); i++)
{
if (TabPage[i] == stackedpagenumber)
{
TabPage.removeAt(i);
this->removeTab(i);
return;
}
}
}
void QMyCustomTabBar::InsertTabWithNo(unsigned short int stackedpagenumber, const QString &TabString)
{
// see if we have a tab we need to insert it before...
for (int i = 0;i < this->TabPage.count(); i++)
{
if (TabPage[i] > stackedpagenumber)
{
TabPage.insert(i, stackedpagenumber);
this->insertTab(i, TabString);
return;
}
}
// if not, we should insert at the end
this->TabPage.append(stackedpagenumber);
this->addTab(TabString);
}
To copy to clipboard, switch view to plain text mode
Bookmarks