Results 1 to 3 of 3

Thread: How to access Quit Slot without aplication pointer...

  1. #1
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How to access Quit Slot without aplication pointer...

    How can I simple open a program perform some actions and then close it?
    Already tried:
    Qt Code:
    1. QTimer::singleShot(10, &a, SLOT(quit()) );
    To copy to clipboard, switch view to plain text mode 
    Inside the mainform... but I do not have access to the application pointer...


    Base code for what I want:
    Qt Code:
    1. msgBox.setText("Bla bla bla");
    2. QPushButton *opt1 = msgBox.addButton(tr("First One!"), QMessageBox::ActionRole);
    3. QPushButton *opt2 = msgBox.addButton(tr("Second One!"), QMessageBox::ActionRole);
    4. msgBox.setDefaultButton(opt2);
    5. msgBox.setIcon(QMessageBox::Warning);
    6. msgBox.exec();
    7.  
    8. if(msgBox.clickedButton() == opt1)
    9. {
    10. //some actions...
    11. //Close the entire program!
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to access Quit Slot without aplication pointer...

    By the way.. we cant forget that Qt still is C++ related so...
    this solves everything:
    Qt Code:
    1. exit ( 0 );
    To copy to clipboard, switch view to plain text mode 

    thanks anyway

  3. #3
    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: How to access Quit Slot without aplication pointer...

    Quote Originally Posted by Cayan View Post
    Qt Code:
    1. exit ( 0 );
    To copy to clipboard, switch view to plain text mode 
    That's a bad way to exit a GUI app. If you need a pointer to your application use QCoreApplication::instance() or the short hand qApp.

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.