Adding button to QTabWidget tabs
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();
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.
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;
Let me explain it with this picture
Ok. That's what I tried to say with my piece of code :)
So you just have to create a base class for all your tabs, like the one in my previous post.
If you want to force your QTabWidget to use it only, you will have to sub-class QTabWidget.
Thank you tilsitt !
I am going to try it and post the result.
In the GUI right click QTabWidget and select add page :)