View Full Version : Widgets visual update / synchronization

Caius Aérobus
16th November 2007, 13:54
I have a slot, whose code is below :
this->Print("-> received");
this->Print("-> executed");
current_text being a QLineEdit.
My problem is that the slot is executed synchronously - I mean the prints occurs at the right time, i.e. immediately next to each computation step has been completed, BUT the number displayed in the QLineEdit is only updated after all steps have been completed. So there is a delay between the time at which the setText() is executed and the time at which the widget display is updated. How to cope with this issue?
Thanks in advance for your help.


16th November 2007, 15:23
two hints, first:

void QWidget::update () [slot]
Updates the widget unless updates are disabled or the widget is hidden.
This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.

so use repaint instead...

Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden.
We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker.

second - make sure that you have updatesEnabled property set to true.

16th November 2007, 17:02

Caius Aérobus
27th November 2007, 13:47
Back to you.
I have checked the updatesEnabled property, tried processEvents() call, but still does not work.
I have also tried the QCoreApplication::flush() solution, as advised in the Qt documentation but nothing has changed.
My display function appears as follow:

class wlFieldImage : public QLabel


FieldImage:: paintEvent(QPaintEvent *event)

[ some drawings ]
printf("paint done\n");

The prints appear during the simulation but the image display only appears at the end.
Any help?

27th November 2007, 13:52
How and where did you call processEvents()?