Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT GUI -> Mutiple views in a single window

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.

like image 226
user1553046 Avatar asked Oct 07 '14 19:10

user1553046


1 Answers

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:

enter image description here

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.

like image 88
Kosovan Avatar answered Oct 27 '22 19:10

Kosovan