Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Working on multiple screen issue
My problem is similar to the given issue.
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.
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
So 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.
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:
"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 :)
@Kira That post refers to creating the widgets dynamically if I understand it correctly
I'm still not sure about your exact use case: do you create the "screen" dynamically?
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.
@mrjj : Ok thanks :)
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.
@mrjj : Tag name?
Well i mean - use a name instead of the raw index.
emit GotoPage( "EditPage" )
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
@mrjj : Ohh sure thanks :)