Qtimer and Qlabel
-
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 );
@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_msgis not a functor, it's (presumably) aQLabelvariable....What about:
ui->label_camera_msg.setText("Something"); QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText(""); } );?
-
@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_msgis not a functor, it's (presumably) aQLabelvariable....What about:
ui->label_camera_msg.setText("Something"); QTimer::singleShot(5000, this, [this]() { ui->label_camera_msg.setText(""); } );?
-
@JonB no need for a lambda here
QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear ); -
@JonB no need for a lambda here
QTimer::singleShot(5000, ui->label_camera_msg, &QLabel::clear );@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 secondui->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-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 secondui->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-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 secondui->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");@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"); } ); -
@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"); } );