Switching between multiple ui forms in Qt
Asked Answered
S

1

6

I am developing the user interface for a embedded device. I have created about 30 ui forms. You have first the Welcome form which loads the database and connects automatically to the available known wifi and all those start up functions. Once everything is loaded the next form to be loaded is the user login

So this is how I go about it, if Login is my second ui

//Instantiating the Login class
Login *myLog = new Login();

//Close the welcome class
this->close();

//open the Login class
myLog->show();

Is this the right way to switch between multiple UI? The software can be imagined like any smart phone device with multiple Icon buttons to open different apps. And each app or folder has a functionality of its own. I have a home button to move back to main menu homepage and so on. I have used the above given code to switch between various ui forms and I am not sure if this is the way to go about it. I am very new to Qt and I was asked to do this task within 2 weeks and I created the easiest way I found. Is there a better way to go about it?

Any help or guidelines is appreciated. If you could give me links to understand better it would be great

Thank you

EDIT enter image description here

Every ui form has a short cut panel for direct access to login, main menu, settings-power options, wifi options (within settings). The layout flow shown under 1 is similar to 2, 3 and settings. Sorry for the ugly image. The two way arrow indicates i can switch back and forth. The single arrow shows linear movement.

Sluiter answered 10/1, 2014 at 9:36 Comment(7)
It depends. Can the "apps/uis" changed in any random order, is it more like a wizzard? Please clarify the UI workflow a bit more.Ingressive
It is not a linear movement. It is more like tree structure. With short cut panel below that helps access the settings ui, main menu directly. The link you provided wouldn't help much. The software to be designed has a UI like a smart phone basically.Sluiter
Please do some mock-ups (or just take screenshots in your case), and attach those to your question. It is worth of million words. In any case, I would use QStackedWidget most probably rather than your show/hide code.Ingressive
use stacked widget with the valid index as laszlo said . u can use the index of the stacked widget to show the respected Ui. qt-project.org/doc/qt-5.0/qtwidgets/dialogs-configdialog.html see this example .Robeson
@Laszlo Papp I will read up on QStackedWidget as suggested by you and see if it works. Thank you for the suggestionSluiter
@Robeson Thank you for the suggestion. I will read up on QStackedWidgetSluiter
I propose you to learn about state machines in Qt - qt-project.org/doc/qt-4.8/statemachine-api.html . It will make coding of such things more clearly.Continuo
S
8

Is there a better way to go about it?

I think so.

As noted in the comment, I would use a QStackedWidget myself.

I think this blog post explains how to establish "Home", "First" and so forth widgets inside it. This should be useful for you:

How to use Qstackedwidget in Qt (Switching between multiple views in Qt)

Shuma answered 10/1, 2014 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.