How to add a widget to QMainwindow in qt creator
-
wrote on 9 Oct 2017, 11:48 last edited by
/QTabWidget *tabWidget = new QTabWidget;
/*QWidget *tab1 = new QWidget; QWidget *tab2 = new QWidget; QWidget *tab3 = new QWidget; setCentralWidget(tabWidget); tabWidget->insertTab(0,tab1,"Table_1 Data"); tabWidget->insertTab(1,tab2,"Table2 data"); tabWidget->insertTab(2,tab2,"Table3 data");
// tabWidget->tabRemoved(0);
// ui->tabWidget->removeTab(0);
tabWidget->removeTab(2);
Here i manually creating the widgets there are attaching with QMainwindow ....I dont want to create manually need to dynamically open it need to attached to Qmainwindow....... -
/QTabWidget *tabWidget = new QTabWidget;
/*QWidget *tab1 = new QWidget; QWidget *tab2 = new QWidget; QWidget *tab3 = new QWidget; setCentralWidget(tabWidget); tabWidget->insertTab(0,tab1,"Table_1 Data"); tabWidget->insertTab(1,tab2,"Table2 data"); tabWidget->insertTab(2,tab2,"Table3 data");
// tabWidget->tabRemoved(0);
// ui->tabWidget->removeTab(0);
tabWidget->removeTab(2);
Here i manually creating the widgets there are attaching with QMainwindow ....I dont want to create manually need to dynamically open it need to attached to Qmainwindow.......@veera said in How to add a widget to QMainwindow in qt creator:
I dont want to create manually need to dynamically open it
But using addTab or insertTab IS dynamically ???????
as versus just adding them in Designer. -
wrote on 9 Oct 2017, 12:47 last edited by
okay fine how about the display of the tabs need join to main window how we can achieve it ?
-
okay fine how about the display of the tabs need join to main window how we can achieve it ?
- display of the tabs need join to main window
the tabs are widgets. you can add any the widgets to main window if you use a layout or another tabwidget.
if you need them as tab still, then another tabwidget is needed.
else im not sure what you mean by "join"
-
wrote on 9 Oct 2017, 13:26 last edited by
okay thanks for the support i will try now ...
-
Hopefully it answered what you asked.
I not sure what your real issue was, what you have tried and what didnt work :) -
wrote on 10 Oct 2017, 07:22 last edited by
-
Hi In the screen below image I have mentioned like this type in one mainwindow button need to implement i could not understand how to start ........please help me
@veera Sorry, it is really hard to understand you. Isn't this just a QTabWidget containing another QTabWidgets in its tabs?
-
wrote on 10 Oct 2017, 07:48 last edited by
No it should have some control if you click it it has to open it as a tab need to open as you can see in the image i have uploaded?
-
No it should have some control if you click it it has to open it as a tab need to open as you can see in the image i have uploaded?
@veera You can either use real buttons or qtabwidget containing other qtabwidget and react on tab switch using
http://doc.qt.io/qt-5/qtabwidget.html#currentChanged
But I don't really understand what you're asking for... -
wrote on 10 Oct 2017, 09:46 last edited by
I have shown in the image .....i dont need full implementation i just need a sample of the image with only one control needed thats it.
-
wrote on 10 Oct 2017, 09:49 last edited by
single menus control with whenever if you click means it has to open a page or tab with (close X) on it ......thats it.
-
single menus control with whenever if you click means it has to open a page or tab with (close X) on it ......thats it.
@veera What is exactly the problem? You can just connect a slot to clicked() signal of a push button (if you use a push button) and show what ever you need in that slot.
-
wrote on 10 Oct 2017, 12:24 last edited by
-
please find my screen shots these dialog boxes are opening separately ...i don't want to open it separately need to join them to main window as well as it will not allow to do anything after closing window only we can open another window.....
@veera If you don't want to open them as windows than don't do it. It looks like you're using dialogs - dialogs are per definition windows! Add those widgets to their parent widget.
-
wrote on 10 Oct 2017, 13:14 last edited by
Qt designer form class is widget .....after that how to add widgets to their parent widget ?
-
wrote on 12 Oct 2017, 08:16 last edited by
Well... every widget has the setParent(QWidget *parent) function. is that not working for you?
36/43