How to add a widget to QMainwindow in qt creator
-
wrote on 7 Oct 2017, 06:53 last edited by
Thanks for your valuable reply.......if add any dialog designer class without button to my qt project if there is a pushbutton in mainwindow.ui after that dialog window is opening it separately...i don't want to open it has a seperate window .....that has to attached to mainwindow as a tab.......in screen sheet you can see it.......
-
wrote on 7 Oct 2017, 07:29 last edited by veera 10 Jul 2017, 07:31
How to display a widgets inside a main window as a tabs?
-
Lifetime Qt Championwrote on 7 Oct 2017, 10:11 last edited by mrjj 10 Jul 2017, 10:14
@veera
Just place it on the form, right click and choose Insert Page
You can then add widgets to it.
-
wrote on 7 Oct 2017, 10:33 last edited by veera 10 Jul 2017, 10:34
-
Lifetime Qt Championwrote on 7 Oct 2017, 10:34 last edited by mrjj 10 Jul 2017, 10:37
Ok but it has function for that.
http://doc.qt.io/qt-5/qtabwidget.html#addTab
so you can also do it run time. -
wrote on 9 Oct 2017, 10:59 last edited by
okay ....how to open the qtabs widget after pressing pushbutton from the mainwindow during the run time?
-
okay ....how to open the qtabs widget after pressing pushbutton from the mainwindow during the run time?
you mean after you called addTab to add it ?
-
wrote on 9 Oct 2017, 11:07 last edited by
No it has to call Qtabwidget with single tab...
-
wrote on 9 Oct 2017, 11:14 last edited by
is it possible to implement ??
-
Lifetime Qt Championwrote on 9 Oct 2017, 11:14 last edited by mrjj 10 Sept 2017, 11:16
Hi
Who has to call ?
You can use addTab to add a tab
and u show() to show itDo you have the tabwidget in UI file?
You from button you just add tab.
Tab can be any widget you like. -
wrote on 9 Oct 2017, 11:19 last edited by
Hi ,
No ....need to call in the run time There is Qmainwindow ui in that i have implemented there is a open pushbutton using style sheet ,if i press its has to open qtabwidget after words .....i will show my tableview in that ,its already connected with database server ..........this is my implementation idea.... -
Hi ,
No ....need to call in the run time There is Qmainwindow ui in that i have implemented there is a open pushbutton using style sheet ,if i press its has to open qtabwidget after words .....i will show my tableview in that ,its already connected with database server ..........this is my implementation idea....ok if you new a tabwidget with no parent, it should become window
then you just a page to it and it should be it -
wrote on 9 Oct 2017, 11:25 last edited by
how to add and open the page after click the button?
-
wrote on 9 Oct 2017, 11:26 last edited by
if you don't mind please elaborate the concepts.....
-
Lifetime Qt Championwrote on 9 Oct 2017, 11:29 last edited by mrjj 10 Sept 2017, 11:38
I think i dont understand what you are asking.
void MainWindow::on_pushButton_2_released() { QTabWidget* tw = new QTabWidget(nullptr); tw->addTab(new QPushButton("test"),"MYTAB"); tw->show(); }
Will show a tabwidget as window with one Qpushbutton as tab
Note. just sample. it will make new each time pushed and not delete it.
A dialog would work better. -
wrote on 9 Oct 2017, 11:44 last edited by
sorry the main thing is that it has to open as a tab attached to main window ......
-
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"
20/43