Working on multiple screen issue
-
Hello All,
My problem is similar to the given issue.
https://forum.qt.io/topic/56168/how-to-handle-multiple-screens-on-the-gui/4
Currently, I am using stacked widgets, but I need to switch within the screen.
There is a solution mentioned in the forum, is there an example referring the same
or is there any other alternative solution since it was discussed long back. -
Hi
The stacked widget approach is still the one to use for any design using a concept of "pages"For wizard like design, there is also
https://doc.qt.io/qt-5/qwizard.htmlSo what is the actual issue you have?
-
@mrjj: Thanks for the reply.
Currently, I have a main window with a stack widget.
I have inserted five widgets, ie. 5 pages of stacked widgets.
Each widget has its own independent functionality.
Now suppose there is a push button on page1 using which I have to call page4
How this is possible?
For example, the child widget won't have an idea about the parent widget. -
@Kira said in Working on multiple screen issue:
How this is possible?
Connect the signal to a slot in the container widget (I guess MainWindow?) where you activate the page 4?
-
@jsulm: Ok thanks understood.
I was referring to one of the comments mentioned by the moderator in the given link:
https://forum.qt.io/topic/56168/how-to-handle-multiple-screens-on-the-gui/4
"I would give it a generic addScreen(Screen) function and then load them at runtime. This way you would design main window and each screen separately in the designer keeping them nice and separate*."
Any comments on that :) -
Hi
I think the other tread just talk about using full UI enabled widgets with .cpp and .h
Just like MainWindow is. based on QWidget instead. ( as base class)That allows you to handle all functionality inside its .cpp file and not stuff all logic from pages into the mainwindow.
So to allow such self-contained Widgets to change page you need to define some new signals pr page it can emit and then
mainwin can do the page flipping. Or a small controller object if you wish to keep it really clean. -
Ok so thats why he talks about addScreen(Screen) as if we use a custom Widget as the page then
we need to use promotion or insert via code.If you need to be able to jump to random pages, from a page, i will recommend you use a tag name instead of the raw int index
as then inserting or remove pages later will not break the jumping. -
Well i mean - use a name instead of the raw index.
like
emit GotoPage( "EditPage" )
versus
emit GotoPage( 6 )if you would ever change the flow or add new pages in the middle its nice
not to have to change all the index around the interface.I used a dynamic property for this. you can also use Widget objectname