PDA

View Full Version : QPushButton SetText



Ferric
26th October 2010, 04:42
Hi, I am trying to change the text displayed on a button as soon as the button is clicked.

I can change it fine by using SetText, but, it only shows the updated text after everything else in the slot has been completed.

What could I use to update the buttons text 'instantly'?

tbscope
26th October 2010, 05:31
Do you use the mouse press event ?

Ferric
26th October 2010, 07:25
Hi, Thanks, no Im not using mousePressEvent. I cannot find how I could use mousePressEvent to help me.

Is there a command I can write that will update the button/GUI instantly? I have tried a few but none of them seem to do the trick.

Lykurg
26th October 2010, 08:14
change the text at the beginning of the slot and call e.g. QCoreApplication::processEvents(). Or do everything else in a thread.

Ferric
26th October 2010, 08:29
Thank You, using QCoreApplication::processEvents() works well. Using a thread is a little over my head at this stage.

wysota
26th October 2010, 09:17
Thank You, using QCoreApplication::processEvents() works well. Using a thread is a little over my head at this stage.

Try resizing the window while "everything else" works or move some other window over the window of your application. See if this is something you really want for your users.

Ferric
30th October 2010, 00:59
I know what you are saying Wysota.. My application is not as professional as it could be. One day I will hopefully find the time to comprehend using threads.