Adding button to QTabWidget tabs
-
Hi everyone,
I have created a QTabWidget and it's tab count changing dynamically when a signal is triggerd. I have add tabs like@
QWidget *centralWidget = new QWidget();
ui->tabWidget->addTab(centralWidget,client->peerAddress().toString());
@
Everything is okey by now, but the problem is i want to add button to this tabs/centralWidget.Is there anyway to do it?
Thanks in advance.
-
Hi,
if you want to add a button on a specific tab (e.g. a close tab button), you can use "setTabButton()":http://qt-project.org/doc/qt-4.8/qtabbar.html#setTabButton on the tab bar.
if you want to add a button to the tab widget itself (e.g. an add tab button), I think "setCornerWidget()":http://qt-project.org/doc/qt-4.8/qtabwidget.html#setCornerWidget is what you are searching.
-
Both "setTabButton()" and "setCornerWidget()" is not what i want. I want that button to inside the "tab" not the tab header section. In the tab. For example, I have 5 tabs and i select the third tab, i want to see this button inside this particular tab.
-
You mean something like that:
@
class MyPage : public QWidget
{
void addButton(QPushButton* button);
void setContents(QWidget* widget);
};MyPage *page = new MyPage;
QWidget *centralWidget = new QWidget;page->setContents(centralWidget);
page->addButton(new QPushButton);ui->tabWidget->addTab(page, ,client->peerAddress().toString());
@ -
Let me explain it with this picture
-
Thank you tilsitt !
I am going to try it and post the result. -
In the GUI right click QTabWidget and select add page :)
-
Dear Thehillmisu,
I have the same problem. I would like to add a QChart to a tab in tabWidget. I came so long that I can show it in main window using following but I don't know how to access to the tabWidget itself:ui->setupUi(this);
this->setCentralWidget(chartView);Thanks in advance!
-
Hi everyone,
I have created a QTabWidget and it's tab count changing dynamically when a signal is triggerd. I have add tabs like@
QWidget *centralWidget = new QWidget();
ui->tabWidget->addTab(centralWidget,client->peerAddress().toString());
@
Everything is okey by now, but the problem is i want to add button to this tabs/centralWidget.Is there anyway to do it?
Thanks in advance.
Dear Thehillmisu,
I have the same problem. I would like to add a QChart to a tab in tabWidget. I came so long that I can show it in main window using following but I don't know how to access to the tabWidget itself:ui->setupUi(this);
this->setCentralWidget(chartView);Thanks in advance!