I'm creating a GUI for an industrial machine, I would like to have a "main" window that displays general status information that has ability for the user to click on a icon and have the gui seamlessly switch to a different view. For instance, there is a warning icon on the main window, they click on it and the window transitions into a detailed status page for that subsystem.
My problem is that I have not found a good method of accomplishing this in QT. I could open up a new window but I don't want the user to have manage multiple windows, tabs have some of this functionality but I do not want the user to have to click on/manage tabs. I tried several options revolving around hiding/showing components, but the fact I couldn't define multiple layouts on the same window and have a sane way to manage and switch between them stumped that approach.
So in short, I would like to have a single screen with no tabs, filled with icons/status widgets, have the user be able to click on a widget(one that turns red, for instance) and (from the user perspective) all the main widgets disappear and are replaced by a detailed view on that subsystem, then when the user is done with that view, they are quickly able to transition back to the main status page. Does this make sense?
Any advice on how to approach this? Thanks all.
Use QStackedWidget
:
Link: http://qt-project.org/doc/qt-4.8/qstackedwidget.html
You can place different widgets with addWidget ( QWidget * widget )
method. Connect one of the button to the appropriate slot which will change widgets using setCurrentIndex ( int index )
method.
If you work with QMainWindow
subclass, you can set QStackedWidget
as a central widget.
Look at this picture:
Every widget (1,2,3,...) can have layout with other child widgets (for example for showing different data) and can be added to QStackedWidget
. After this you should only setCurrentIndex
to show one of this widgets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With