Solved how to add down counter into thread which called from main thread per 2 ms?
-
i have called below slot from my thread . but i am unable to see down counter. if i use same code in other application . then this code work fine . what extra thing i need to add to see down counter in thread ?
how to represent exact one second down counter in thread ?
in below code what change i need to do to get exact one second down counter in thread?
void MainScreen::shutdownlabel()
{
qint64 Newtime = QDateTime::currentMSecsSinceEpoch() - mtime;
//PRINT_INFO<<"newtime: " << Newtime/1000;
Timeremain = TIMEOUT - (Newtime/1000);
label->setStyleSheet(SS_MAINSCREEN_LABEL);
label->setAlignment(Qt::AlignHCenter);
label->setGeometry(150,3,43,22);
label->clear();
if(!Timeremain)
{
label->setText("shut down");
label->deleteLater();
}
else
{ if(Timeremain %2 )
{
label->setText(sTimer()+QString::number(Timeremain/2));
qDebug()<<sTimer()+QString::number(Timeremain/2);
}
else
label->setText(" ");
}
label->show();if(Timeremain!=0)
QTimer::singleShot(1000,this, SLOT(shutdownlabel()));}
-
@Qt-embedded-developer And what is the problem? If your counter is 500ms and you can't change that then trigger the action on every second timeout...
-
@Qt-embedded-developer Please provide more information about what you want to do - it is really unclear!
And please format the code properly - it is hard to read... -
my requirement is to show alternate icon and text representation at 1000 msec inside thread. thread is running at every 500 msec.
-
@Qt-embedded-developer And what is the problem? If your counter is 500ms and you can't change that then trigger the action on every second timeout...