Results 1 to 8 of 8

Thread: How to confirm the clean exit of QApplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2013
    Location
    Everett WA USA
    Posts
    12
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to confirm the clean exit of QApplication

    Dear experts,


    I am working on one project where I use Qt for GUI development. Qt is running at the main thread. I would like to confirm the clean exit of the QApplication. This is required to do some post application exit operation such as running exit handlers.

    When the application needs to exited I use,

    qApp->quit();

    to confirm the successful exit of the QApplication, I use

    if ( true == qApp->closingDown())
    {
    //Successfull exit of the QApplication. Do post exit operations
    }


    Questions:
    a. Does qApp->quit() immediately makes qApp->closingDown() function to return the true value.
    b. Are there any other way to confirm the successful exit of the QApplication?

  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: How to confirm the clean exit of QApplication

    You can cleanup after QApplication::exec() returns before returning from main().

    Qt Code:
    1. int main(...) {
    2. QApplication app(...);
    3.  
    4. int ret = app.exec();
    5. doCleanup();
    6. return ret;
    7. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to confirm the clean exit of QApplication

    How about QCoreApplication::aboutToQuit signal ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to confirm the clean exit of QApplication

    I guess it mosly depends on whether you need the event loop during cleanup.
    If you do, Lesiok's suggestion would give you that, if you don't, I'd also go for Wysota's suggestion.

    Cheers,
    _

Similar Threads

  1. A problem about "undefined reference to `Clean::Clean(QObject*)'
    By GeorgeDao123 in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 10th February 2013, 09:36
  2. Replies: 2
    Last Post: 27th July 2011, 04:24
  3. How works QApplication::exit()
    By anoraxis in forum Newbie
    Replies: 5
    Last Post: 12th April 2011, 20:13
  4. Clean Exit of QWSServer
    By ssc in forum Qt Programming
    Replies: 0
    Last Post: 11th January 2011, 12:55
  5. clean exit!!
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2008, 16:33

Tags for this Thread

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.