Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. how to add down counter into thread which called from main thread per 2 ms?
Forum Updated to NodeBB v4.3 + New Features

how to add down counter into thread which called from main thread per 2 ms?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 516 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by Qt embedded developer
    #1

    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()));

    }


    jsulmJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      @jsulm

      my requirement is to show alternate icon and text representation at 1000 msec inside thread. thread is running at every 500 msec.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • Q Qt embedded developer

        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()));

        }


        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        1
        • jsulmJ jsulm

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

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #3

          @jsulm

          my requirement is to show alternate icon and text representation at 1000 msec inside thread. thread is running at every 500 msec.

          jsulmJ 1 Reply Last reply
          0
          • Q Qt embedded developer

            @jsulm

            my requirement is to show alternate icon and text representation at 1000 msec inside thread. thread is running at every 500 msec.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

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

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved