Solved How to display Label for 30 seconds and then hide it?
-
@jsulm
I my case, I tried to implement this but it shows error. -
@Mijaz said in How to display Label for 30 seconds and then hide it?:
I my case, I tried to implement this but it shows error.
Which error exactly? Please show your code.
Regards
-
@Mijaz said in How to display Label for 30 seconds and then hide it?:
Will you send me an example
No, because there are already examples (you can find them in the link I sent you before):
See also QBasicTimer, QTimerEvent, QObject::timerEvent(), Timers, Analog Clock Example, and Wiggly Example. -
-
You create a new timer everytime your slot
on_APush_clicked()
is called. Make the timer a member variable and create it once.timer->start()
without parameters should work.Then the only needed step is to create a slot that does whatever you want.
Regards
-
connect(..., ui->flashing_text->setText("..."));
The last parameter to
connect()
must be either a function/method or a lambda, which in turn will execute thesetText()
you show. You cannot have it be the actual function call you are trying. This is the cause of the error message you see.It would help you if you read up on Qt signals & slots, https://doc.qt.io/qt-5/signalsandslots.html.
-
@aha_1980
I have created new simple project. it shows all ok but still not blinking. -
@Mijaz In the screen-shot you posted you still call singleShot!
Did you read the link I posted? There are even examples:QTimer *timer = new QTimer(this); connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update)); timer->start(1000);
Just connect your own slot to timeout and in that slot toggle the label...
-
@MhM93
thank you... -
@RAJALINGAM
can you please share your form window