Results 1 to 3 of 3

Thread: why teminate only works with quit() and not any other

  1. #1
    Join Date
    Jan 2007
    Posts
    8
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Question why teminate only works with quit() and not any other

    In the below code when the quit() is replaced with a fuction say myquit(), Why doesn't my app/window terminate? It only works where SLOT( quit()) ) why?

    thanks.

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qpushbutton.h>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. QPushButton *button = new QPushButton("Quit", 0);
    8.  
    9. QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit()));
    10. app.setMainWidget(button);
    11. button->show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 28th January 2007 at 13:51. Reason: missing [code] tags

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: why teminate only works with quit() and not any other

    bec QApplication doesnt have the method myquit().

    QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit()));
    You are connecting clicked() signal of button object with quit() slot / method of app object. app is an object of QApplication class, and u can call only those slots which are present in the class...

  3. #3
    Join Date
    Jan 2007
    Posts
    8
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: why teminate only works with quit() and not any other

    Thanks I thought it had to be the name of our project/app function. It works great.

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
  •  
Qt is a trademark of The Qt Company.