maratk1n
14th May 2017, 20:39
Hi all!
Tell me, please, how can I make a delay before the next action. In this case, I still need to update the progress bar.
void ClassName::start()
{
action1();
/*
Here I need to wait a while, update the progress bar, and go further
*/
action2();
emit finished();
}
I tried to do it this way, but it does not work.
void ClassName::start()
{
emit mainLabelEmit(QString("кек"));
QTimer *timer = new QTimer(this);
timer->setSingleShot(true);
timerCount = 10;
//timer = new QTimer();
timer->start(timerCount * 1000);
while (timer->remainingTime() >= 0)
{
QString smallLabel = QString("Left %1 sec").arg(timer->remainingTime() / 1000);
//qDebug() << smallLabel;
emit smallLabelEmit(smallLabel);
if (timer->remainingTime() == 0)
{
timer->stop();
emit smallLabelEmit(QString(""));
}
else
{
emit progressBarEmit(100 - 100 * timer->remainingTime() / timerCount);
}
}
for (int i = 0; i < 7; i++)
{
emit open(i);
}
for (int i = 0; i < 7; i++)
{
emit close(i);
}
emit finished();
}
Thanks!
Tell me, please, how can I make a delay before the next action. In this case, I still need to update the progress bar.
void ClassName::start()
{
action1();
/*
Here I need to wait a while, update the progress bar, and go further
*/
action2();
emit finished();
}
I tried to do it this way, but it does not work.
void ClassName::start()
{
emit mainLabelEmit(QString("кек"));
QTimer *timer = new QTimer(this);
timer->setSingleShot(true);
timerCount = 10;
//timer = new QTimer();
timer->start(timerCount * 1000);
while (timer->remainingTime() >= 0)
{
QString smallLabel = QString("Left %1 sec").arg(timer->remainingTime() / 1000);
//qDebug() << smallLabel;
emit smallLabelEmit(smallLabel);
if (timer->remainingTime() == 0)
{
timer->stop();
emit smallLabelEmit(QString(""));
}
else
{
emit progressBarEmit(100 - 100 * timer->remainingTime() / timerCount);
}
}
for (int i = 0; i < 7; i++)
{
emit open(i);
}
for (int i = 0; i < 7; i++)
{
emit close(i);
}
emit finished();
}
Thanks!