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.
Bookmarks