Results 1 to 3 of 3

Thread: Quitting before the QApplication::exec()

  1. #1
    Join Date
    Mar 2006
    Location
    Moldova
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Quitting before the QApplication::exec()

    Hi all.

    I have an application that works with databases. Before it starts executing it shows a dialog that asks for the connection parameters (user, password). I'd like to make that when a user presses the Cancel button, the application must quit.

    For example:

    Qt Code:
    1. //-------------------------//
    2. int ret = ConnDialog.exec();
    3. if (ret == QDialog::Rejected)
    4. app.quit();
    5. //-------------------------//
    6. app.exec(); // Here starts the main loop
    7. //-------------------------//
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work. The QApplication::quit() works only inside the main loop.
    How can i quit the application before the main loop ? Thnx ...
    All Rights Reserved ...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Quitting before the QApplication::exec()

    Simply return from main().
    Qt Code:
    1. int main(...){
    2. //...
    3. if(ret == QDialog::Rejected)
    4. return 1;
    5. return app.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Location
    Moldova
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Quitting before the QApplication::exec()

    Oh ! Shame to me ! My mind is giving up after 2 days of hard work on this app ....

    Thnx a lot !
    Last edited by jsmax; 17th April 2008 at 20:33.
    All Rights Reserved ...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.