Results 1 to 2 of 2

Thread: Standard Exit button usage

  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Standard Exit button usage

    Standard Exit button
    Hello Qt experts,

    I have the application with .ui file specified in Qt Designer. The application starts several processes during execution. Question is about their termination.
    I have already manage to close them with the button I created.
    However I would like to do it by clicking standard Exit button [X]. How can I use that button to close gracefully all the active processes?

    The main function is a standard one:
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "myqtapp.h"
    4.  
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. myQtApp *dialog = new myQtApp;
    10.  
    11. dialog->show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    The application is as follows:

    Qt Code:
    1. myQtApp::myQtApp(QWidget *parent)
    2. {
    3. setupUi(this); // this sets up GUI
    4.  
    5. RWS_start(); // this function starts process/processes
    6.  
    7. connect( _quit, SIGNAL( clicked() ), this, SLOT( quit() ) );
    8.  
    9. }
    10.  
    11. myQtApp::~myQtApp()
    12. {
    13.  
    14. }
    15.  
    16. void myQtApp::RWS_start(){
    17.  
    18. QProcess *process = new QProcess(this);
    19. QString Path = "C:\\Robostacker\\RWS\\RobWorkStudio.exe";
    20. process->start(Path, QStringList() << "");
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    It would be interesting to add the Window which ask user if is sure that want to close the application.
    The Window should appear after click the standard Exit button [X].
    Any tips or even better the examples to solve that best?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Standard Exit button usage

    QWidget::closeEvent

Similar Threads

  1. Exit unending loop with Button
    By Roelof in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2009, 13:20
  2. Exit button that does a task before exiting
    By Roelof in forum Qt Programming
    Replies: 5
    Last Post: 11th September 2009, 14:21
  3. stylesheet standard button names
    By h123 in forum Qt Programming
    Replies: 0
    Last Post: 14th April 2009, 12:42
  4. Replies: 2
    Last Post: 2nd June 2008, 08:45
  5. Window without a exit button
    By jbpvr in forum Qt Programming
    Replies: 4
    Last Post: 12th March 2007, 23:54

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.