[SOLVED]QMainwindow
-
Is it possible to create a home button from a widget window to the main window
-
Hi
What do you mean ?If you mean create another widget as window and there then
have a buttons that close the
current windows and shows MainWindow again.
Then yes.You can also use dialogs and it will pop over the mainwin and when closed then
mainwin is under.if you making something what would be like pages and do not really need to be windows, the
stacked widget is also good. -
Well, you can show any window from any window.
Have a look at this mini sample and tell me if that is what you mean or
you have other needs. -
@Gillou_beginqt
ok.
here is one that does that using signals
https://www.dropbox.com/s/ic7ecp8iql1xkje/gilltest2.zip?dl=0 -
You can use "stacked widget" concept which do what you want.
Please see the below documentation for more details.
http://doc.qt.io/qt-4.8/qstackedwidget.html -
@mrjj Your answer is basically what i want to do. Thank you but with many sub windows of sub windows I'll difficult for me. The stackwidget seems adequate for my project
@Ajith_P_V Can you elaborate? I tried the but my program stops -
@Gillou_beginqt Basically, stacked widget is a concept which will show either of the "page(or screen)" at a time. Create a widget project in Qt creator. Drag and drop the stacked widget item from the panel. Then in stacked widget, create your main window page followed by creating your sub window(s) as another page(s). In this way, while running your project, first your main window page will appear with your desired button. When you click on the button, set it to go to the next page (sub window) which also means that, the main window page will get disappear and new page will get displayed! . From your current window page, you can come back to your first page (Main window page) by click on "home" button clicked.
Regards,
Ajith P V -
@Ajith_P_V But If I already created different QWidget windows separately and I want to use the QStacked widget. How can I do it ?
-
Hi
If you created UI files that are based on Widget as parent, you could
place a Widget on the stack page, and use the promote feature (right click)
to get the widgets into the stacked. -
@mrjj I have 3 Pages 1 Qmainwindow and 2 sub windows Qwidget:
- Main window
- Movie widget
- Sport widget
I palced the QStackedWidget on my main waindow and placed all the widgets on page 1
On page 2 I promoted to a qwidget movie which is supposed to appear when you click on a button but nothing happens when I clicked
-
@Gillou_beginqt
and you switch to the page with
ui->stackedWidget->setCurrentIndex(1); ?Sounds like you are almost there.
have a look at this sample
https://www.dropbox.com/s/023mjp464ctdzsm/mystacked.zip?dl=0