Results 1 to 3 of 3

Thread: Closing QCoreApplication by clicking X on top right corner

  1. #1
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Closing QCoreApplication by clicking X on top right corner

    Hi,

    I have a console application that uses QCoreApplication, and it is executed using exec():

    Qt Code:
    1. int main()
    2. {
    3. QCoreApplication qtApp(argc, argv);
    4.  
    5. MsDbServer server;
    6. server.start();
    7.  
    8. return qtApp.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    I want to perform some code clean-up when a user clicks on the "X" button on the top right corner of the console application. How can I detect when this window gets closed in this way?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Closing QCoreApplication by clicking X on top right corner


  3. #3
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Re: Closing QCoreApplication by clicking X on top right corner

    Quote Originally Posted by Lykurg View Post
    I tried connecting that signal but the slot AboutToQuit() doesn't get called (breakpoint doesn't get hit):

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QCoreApplication qtApp(argc, argv);
    4. MsDbServer server;
    5. QObject::connect(&qtApp, SIGNAL(aboutToQuit()), &server, SLOT(AboutToQuit()));
    6. return qtApp.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. class MsDbServer : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public slots:
    6. void AboutToQuit();
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Popup Menu not closing after clicking custom widget
    By stefanadelbert in forum Qt Programming
    Replies: 5
    Last Post: 15th April 2010, 05:38
  2. Round-corner dialogs?
    By WinchellChung in forum Newbie
    Replies: 2
    Last Post: 14th March 2008, 19:47
  3. Button on the Upper Right Corner of MainWindow?
    By vishal.chauhan in forum Qt Programming
    Replies: 10
    Last Post: 12th March 2008, 10:47
  4. QTableView header in corner
    By danstr in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2006, 20:16
  5. [qt4] QScrollArea corner widget?
    By sertrem in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2006, 21:42

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.