QT GUI & # 8594; Multiple views in one window

I am creating a GUI for an industrial machine, I would like to have a "main" window that displays general status information, which has the ability for the user to click an icon, and the gui can easily switch to another view, For example, there is a warning icon in the main window, they click on it and the window goes to the detailed status page for that subsystem.

My problem is that I haven't found a good method to achieve this in QT. I could open a new window, but I don't want the user to control multiple windows, tabs have some of these functionality, but I don't want the user to have to click on tabs / manage tabs. I tried several options revolving around hiding / showing components, but the fact is that I couldn't define multiple layouts in the same window and have a sane way to control and switch between them with a dumb approach.

In short, I would like to have one screen without tabs, filled with status icons / widgets, so that the user can click on the widget (for example, which turns red) and (from the user perspective) all the main widgets disappear and are replaced with a detailed view on that subsystem, while then, when the user is working with this view, they can quickly navigate to the main status page. Does this make sense?

Any advice on how to approach this? Thanks everyone.

+3


source to share


1 answer


Use QStackedWidget

:

Link: http://qt-project.org/doc/qt-4.8/qstackedwidget.html

You can place various widgets using the method addWidget ( QWidget * widget )

. Connect one of the buttons to the corresponding slot, which will change the widgets using the method setCurrentIndex ( int index )

.

If you are working with a subclass QMainWindow

, you can set QStackedWidget

as the central widget.



Take a look at this image:

enter image description here

Each widget (1,2,3, ...) can have a layout with other child widgets (for example to display different data) and can be added to QStackedWidget

. After that, you only need to setCurrentIndex

show one of these widgets.

+2


source







All Articles