PDA

View Full Version : QPushButton setText problem



batileon
2nd December 2008, 12:36
I am having a Q3ButtonGroup with some QPushButton.

I want to update the text of the button when it is being clicked.
Hence I used setText() to perform what I want.
However I found that the setText() doesn't update the ui.
I mean, when I use text() to cout the text of the button, I found that the new text is actually already be set, but in the user interface, I found that it doesn't update at all!!!!
I tried to call all those thing like update()/repaint() after calling the setText but it still doesn't work.

Can anyone tell me what's going on?
Thanks!

drhex
2nd December 2008, 13:14
Calling setText on a QPushButton should update the text onscreen with no need to call repaint/update

Could you make a minimal compilable example program that has the problem and post it here?

jpn
2nd December 2008, 19:38
Perhaps you block the event loop with a busy loop. As long as your function is executing, Qt has no chance to update the buttons.

batileon
3rd December 2008, 04:02
Thanks!
Seems it is really related to the event loop. By adding

QApplication::processEvents();
I solved the problem.