[Qt-interest] the problem of QProgressDialog & QProgressBar
Malyushytsky, Alex
alex at wai.com
Tue Jul 14 11:57:58 CEST 2009
>> But the progress dialogue only shows after( or at the same time) THE SysInfo Dialogue.
>> WHY??
Because of p_ShowSysInfoDlg->exec(); I guess.
I don't think event loop of application is running when you open another modal dialog.
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Gan Xiebin
Sent: Monday, July 13, 2009 11:01 PM
To: qt-interest
Subject: Re: [Qt-interest] the problem of QProgressDialog & QProgressBar
Hi Alex,
Thanks for reply.
I have a code like that,
----------------------
void MainWindow::SysInfoFunc()
{
SysInfoDlg *p_ShowSysInfoDlg = new SysInfoDlg( );
p_ShowSysInfoDlg->exec();
}
SysInfoDlg::SysInfoDlg(QWidget *parent)
: QDialog( parent )
{
textLabel = new QLabel();
thread1.start(); // A task
thread2.start(); // Another task
thread1.wait(); // wait for task finished, and set text to the label
thread2.wait(); // like thread1 ...
textLabel->setText( ... );
}
------------------------------------
I must ensure that the application does not freeze.
I read the document carefully, and used QProgressDialog ...
---------------------------------------------
void MainWindow::SysInfoFunc()
{
progressDlg = new QProgressDialog("Operation in progress.", "Cancel", 0, 100, this);
connect(progressDlg, SIGNAL(canceled()), this, SLOT(cancelProgressDlg()));
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(performProgressDlg()));
timer->start(0);
progressDlg->setValue(0);
SysInfoDlg *p_ShowSysInfoDlg = new SysInfoDlg(node);
p_ShowSysInfoDlg->exec();
progressDlg->setValue(progressDlg->maximum());
}
void MainWindow::cancelProgressDlg()
{
timer->stop();
progressDlg->close();
}
void MainWindow::performProgressDlg()
{
if(progressDlg->value() + 1 < progressDlg->maximum())
{
progressDlg->setValue(progressDlg->value() + 1);
}
else
{
timer->stop();
progressDlg->close();
}
qApp->processEvents();
}
--------------------------------
But the progress dialogue only shows after( or at the same time) THE SysInfo Dialogue.
WHY??
P.S. : I used the model dialogue of QProgressDialog, but have no effect for me.
Thanks.
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090714/85300de7/attachment.html
More information about the Qt-interest-old
mailing list