Results 1 to 13 of 13

Thread: qt window close but process still running

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    5

    Unhappy qt window close but process still running

    I have tried with the lastWindowClosed() but still the while loop is running although the window is close.
    here is some parts of my code;

    QTMainForm::QTMainForm(QWidget* parent)
    {
    btn.setText("start");
    btn2.setText("stop");
    connect(&btn, SIGNAL(clicked()), this, SLOT(OnBtnstrt()));
    progress.setValue(0);

    progress.setRange(0, 1000000);
    progress.setWindowTitle(tr("Find Files"));
    vb.addWidget(&progress);
    vb.addWidget(&btn);
    vb.addWidget(&btn2);
    setLayout(&vb);
    }

    void QTMainForm::OnBtnstrt()
    {

    for (int i = 0; i < 10000000; i++)
    {
    progress.setValue(i);
    qApp->processEvents();
    timer.setInterval(1000);
    if(btn2.isDown())
    {

    break;

    }

    progress.show();
    }
    }

    int main(int argc, char *argv[])
    {

    QTMainForm* pMainForm = 0;

    QApplication app(argc, argv);
    app.setObjectName("client");
    app.setQuitOnLastWindowClosed(true);
    pMainForm = new QTMainForm();
    pMainForm->resize(300, 300);
    pMainForm->show();
    pMainForm->setAttribute(Qt::WA_QuitOnClose);
    QObject::connect( qApp, SIGNAL( lastWindowClosed() ),&app, SLOT( setLastWinClosed() ) );
    return app.exec();
    }

    any help will be really appreciated.
    Last edited by sazzad08; 31st December 2012 at 08:08.

Similar Threads

  1. Replies: 4
    Last Post: 27th June 2012, 10:41
  2. Replies: 1
    Last Post: 10th April 2012, 16:18
  3. Get All Running Process Win32
    By METEOR7 in forum Qt Programming
    Replies: 7
    Last Post: 4th December 2011, 13:05
  4. Get Process ID for a running application
    By bob2oneil in forum Qt Programming
    Replies: 5
    Last Post: 10th September 2011, 21:58
  5. Destroyed while process is still running
    By qtzcute in forum Qt Programming
    Replies: 5
    Last Post: 23rd July 2009, 08:26

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