Not sure what is your long term goal, whatever it be using such a for loop(> 10000000) in button click (or any other slot) will land in to various issues.\
For now to solve the problem, just modify the button click slot
void QTMainForm::OnBtnstrt()
{
double i=0;
while(i<=10000000)
{
i++;
qApp->processEvents();
progress.setValue(i);
if(!isVisible()) // <<<<<<<<<<<<<<<<<<<<<
break;
}
}
void QTMainForm::OnBtnstrt()
{
double i=0;
while(i<=10000000)
{
i++;
qApp->processEvents();
progress.setValue(i);
if(!isVisible()) // <<<<<<<<<<<<<<<<<<<<<
break;
}
}
To copy to clipboard, switch view to plain text mode
One more observation in the main, pMainForm is not being deleted, this is a leak in memory (it will not be a concern now, as the app exits anyway). As a good practice (in Qt) always pass the parent handle to the base classs QWidget/QObject
QTMainForm
::QTMainForm(QWidget* parent
) : QWidget(parent
) // <<<<<<<<<<<<<<<<<<<<<<<<<<< {
...
}
QTMainForm::QTMainForm(QWidget* parent)
: QWidget(parent) // <<<<<<<<<<<<<<<<<<<<<<<<<<<
{
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks