What are the best methods for switching between application windows in Qt?

I have an application with the following user interface formats derived from QMainWindow

  • user appears
  • Taskswindow
  • DetailsWindow

I have to enter the application in LoginWindow, where I will go to TasksWindow. In TasksWindow, I will select an item from the combo box, and then go to the DetailsWindow window and fill in the data related to this item. In the DetailsWindow window, I will have a menu action to bring me back to TasksWindow.

Currently, what I mean (and what I tried) is this. In main.cpp:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    LoginWindow loginWindow;
    loginWindow.showMaximized();

    return app.exec();
}

And in the LoginWindow button:

void LoginWindow::on_loginButton_clicked()
{
        this->hide(); // hide the login window
        TasksWindow tasksWindow;
        tasksWindow.showMaximized();
}

Is there a better way to do this? This becomes unmanageable, because now I have to include a link to every window class I should go to, possibly creating circular links!

, Qt Symbian.

? QStackedWidget , , , .

!:)

+3
2

- State Machine . .

  • State Machine Framework Qt.
  • , Qt, .

a.) , . , , 3 ( ) , , , , . , , / , .

). , , "loggedIn" loginWindow, "loggedOut" TasksWindow, , "loggedIn" Guest .

). , "", , loginWindow. "loggedIn" , "" "", loginWindow , "" , TasksWindow , "".

). , " " TasksWindow, .

). : "" "" "". , , , .

, .

+4

/, .

0

Source: https://habr.com/ru/post/1728921/


All Articles