PDA

View Full Version : Button on QTabWidget



winston2020
23rd October 2008, 21:24
Hi, I'd like to add a "New Tab" button to a QTabWidget. The button should be beside the tab titles. Could someone point me to a tutorial? Or a piece of code?

spirit
24th October 2008, 08:26
this button will be available only in 4.5 in QTabWidget according to this post Some QTabBar & QTabWidget love (http://labs.trolltech.com/blogs/2008/07/02/some-qtabbar-qtabwidget-love/). so, there are too opportunities, the first one: download 4.5 technology preview or add this button by inheriting of QTabWidget. :)

spirit
24th October 2008, 08:43
sorry, I thought that you meen that buttons should be located on each tab, but you mean that this button should be located like "Add page' button in assistant, right? :o

spirit
24th October 2008, 08:45
there is snippet of code how trolls do this in Assistant


...
QToolButton *newTabButton = new QToolButton(this);
ui.tab->setCornerWidget(newTabButton, Qt::TopLeftCorner);
newTabButton->setCursor(Qt::ArrowCursor);
newTabButton->setAutoRaise(true);
newTabButton->setIcon(QIcon(ImageLocation + QLatin1String("addtab.png")));
QObject::connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));
newTabButton->setToolTip(tr("Add page"));
...