A typical desktop app will have only one QMainWindow-based class that holds the entire UI. All other widgets will be children of that and most will be children of whatever is defined as the "central widget" except for some modal dialogs and the decorations around the QMainWindow (menus, toolbars, dock widgets, etc.If I have understood this correct you're only supposed to have one instance of the QMainWindow and all other should rely on QWidget or QDialog?
That is why in almost all of the Qt examples, the C++ main() entry point consists of the same few lines of code: create the QApplication instance, create the main window instance, show() the main window, and exec() the app. The rest of the UI is a tree of widgets that hang off the main window as children, children of children, and so on.
For a case like your login scenario, you could go one of two ways: (1) Have a login dialog appear before the main window is shown to validate the user, and if successful launch the main window from that, or (2) follow the traditional approach of showing the main window, but then immediately post the login dialog. If login is successful, close the dialog, otherwise the dialog calls the main window's close() slot. It is probably easier to take the second approach.
Bookmarks