Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to launch mainwindow from a dialog window?
Forum Updated to NodeBB v4.3 + New Features

How to launch mainwindow from a dialog window?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DanqueDynasty
    wrote on last edited by
    #1

    Ok, so the program starts out with a dialog window requesting information from the user to log on. How can I get the mainWindow to open from the dialog window. Thanks.

    Swing Innovations: http://swinginnovations.com/

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Keozon
      wrote on last edited by
      #2

      Off the top of my head, I would implement it like this.

      Main.cpp
      @
      QApplication a(argc,argv);
      MyMainWindow b;
      return a.exec();
      @

      Note the missing b.show(); command.

      Then, in the constructor for MyMainWindow,

      @
      MyOpenDialog *a = new MyOpenDialog();
      a->exec();
      this.show();
      @

      As long as MyOpenDialog is set as Application Modal, you won't process the this.show() until after the dialog has closed.

      Edit: I should add, if you're all done with MyOpenDialog, you'll want to
      @delete a;@ afterwards this.show();

      I know exactly where my computer is, so I have no idea how fast it's going.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yupifourbi
        wrote on last edited by
        #3

        Dear Keozon,

        Would you mind to show in complete file MyMainWindow.cpp?
        Thanks in advance.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sirius27
          wrote on last edited by
          #4

          bq. MyOpenDialog *a = new MyOpenDialog();
          a->exec();
          this.show();

          i think the a->exec() should be followed by some check-up functions that call the .show() if log in was successful.

          go for it !

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved