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 avoid displaying QMainWindow
Forum Updated to NodeBB v4.3 + New Features

How to avoid displaying QMainWindow

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 2.0k 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.
  • I Offline
    I Offline
    Indrajeet
    wrote on last edited by
    #1

    Hi All

    I have created QApplication project.
    In the constructor I am doing some condition checking and on failure
    that condition i am poping up error message with OK button .
    so when the user clicks OK button my MainWindow should not open.
    How to do this?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      I don't see what's the problem in putting that inside a if statement. Can you elaborate or your problem is really that simple?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on last edited by
        #3

        It is not clear what "should not open" means. If you don't want to start (i.e., load and initialize) the mainwindow then you have to do your check before the window is created (i.e., in the main) and then do a simple if statement. If you mean that the window should be not visible, than in the constructor you can call setVisible with the result of your condition.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          It is trivial:

          @
          int main(int argc, char *argv[])
          {
          QApplication a(argc, argv);

          // check the condition here
          if(checkMyStuff())
          {
              MainWindow w;
              w.show();
          
              return a.exec();
          }
          return 0;
          

          }
          @

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          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