Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qtimer and Qlabel

Qtimer and Qlabel

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 677 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.
  • N Offline
    N Offline
    najlou
    wrote on last edited by
    #1

    hello i would like to display the message of ui->label camera msg only for 5s i used QTimer::singleShot but it does not work could you help me please

    QTimer::singleShot(5000, this ,ui->label_camera_msg );

    JonBJ 1 Reply Last reply
    0
    • N najlou

      hello i would like to display the message of ui->label camera msg only for 5s i used QTimer::singleShot but it does not work could you help me please

      QTimer::singleShot(5000, this ,ui->label_camera_msg );

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @najlou said in Qtimer and Qlabel:

      i used QTimer::singleShot but it does not work

      Well the singleshot timer works.

      QTimer::singleShot(5000, this ,ui->label_camera_msg );

      Doesn't the compiler give an error message for this? ui->label_camera_msg is not a functor, it's (presumably) a QLabel variable....

      What about:

      ui->label_camera_msg.setText("Something");
      QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText(""); } );
      

      ?

      J.HilkJ 1 Reply Last reply
      1
      • JonBJ JonB

        @najlou said in Qtimer and Qlabel:

        i used QTimer::singleShot but it does not work

        Well the singleshot timer works.

        QTimer::singleShot(5000, this ,ui->label_camera_msg );

        Doesn't the compiler give an error message for this? ui->label_camera_msg is not a functor, it's (presumably) a QLabel variable....

        What about:

        ui->label_camera_msg.setText("Something");
        QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText(""); } );
        

        ?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @JonB no need for a lambda here

        QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        JonBJ N 2 Replies Last reply
        2
        • J.HilkJ J.Hilk

          @JonB no need for a lambda here

          QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @J-Hilk said in Qtimer and Qlabel:

          QLabel::clear

          Damn, never noticed that one! :) Thanks.

          1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @JonB no need for a lambda here

            QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
            
            N Offline
            N Offline
            najlou
            wrote on last edited by
            #5

            @J-Hilk @JonB
            thank you for your answer but now it only shows me the second message
            I would like the first one for 5s and after he shows me the second

            ui->label_camera_msg->setText("Capture Caméra Avant");
            QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
            ui->label_camera_msg->setText("Faut faire l'initialisation, Pour le vidéo");

            JonBJ J.HilkJ 2 Replies Last reply
            0
            • N najlou

              @J-Hilk @JonB
              thank you for your answer but now it only shows me the second message
              I would like the first one for 5s and after he shows me the second

              ui->label_camera_msg->setText("Capture Caméra Avant");
              QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
              ui->label_camera_msg->setText("Faut faire l'initialisation, Pour le vidéo");

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @najlou
              So you will need to use my lambda after all :) Adjust it to do what you want when the timer expires....

              1 Reply Last reply
              0
              • N najlou

                @J-Hilk @JonB
                thank you for your answer but now it only shows me the second message
                I would like the first one for 5s and after he shows me the second

                ui->label_camera_msg->setText("Capture Caméra Avant");
                QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );
                ui->label_camera_msg->setText("Faut faire l'initialisation, Pour le vidéo");

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @najlou you're changing the goal post here, but fine, back to lambda we go:

                ui->label_camera_msg->setText("Capture Caméra Avant");
                QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText("Faut faire l'initialisation, Pour le vidéo"); } );
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                N 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @najlou you're changing the goal post here, but fine, back to lambda we go:

                  ui->label_camera_msg->setText("Capture Caméra Avant");
                  QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText("Faut faire l'initialisation, Pour le vidéo"); } );
                  
                  N Offline
                  N Offline
                  najlou
                  wrote on last edited by
                  #8

                  @J-Hilk @JonB thanks you :)

                  1 Reply Last reply
                  1

                  • Login

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