PDA

View Full Version : How to "flush" display?



Caius Aérobus
3rd June 2008, 18:19
Hello,
I have a class inherited from QAbstractItemView in which the mouseReleaseEvent() method have been overloaded so as to perform selection of items. The selection works well and the paintEvent() method is supposed to highlight them. It works well, ie the right items are selected, but I need to cover part of the widget and them show it again for paintEvent() to be executed. I tried almost everything I could think about as a solution, which leads now:

this->update();
QCoreApplication::processEvents();
QCoreApplication::flush();
but paintEvent() is still not synchronously called.
So how to cope with this issue?

marcel
3rd June 2008, 19:27
update just schedules a paint event, it does not trigger an immediate update.
I don't fully understand your problem... Maybe you can elaborate a bit.

Caius Aérobus
4th June 2008, 00:19
update just schedules a paint event, it does not trigger an immediate update.
I don't fully understand your problem... Maybe you can elaborate a bit.

Of course. I just would like to force an immediate execution of paintEvent(), I mean I would like that the paintEvent() be effective immediatement after update().

jacek
4th June 2008, 00:21
I just would like to force an immediate execution of paintEvent(), I mean I would like that the paintEvent() be effective immediatement after update().
You can use QWidget::repaint() instead.

Caius Aérobus
4th June 2008, 19:49
You can use QWidget::repaint() instead.

I did it... but it does not change anything!

Brandybuck
4th June 2008, 21:14
repaint() does not work on all platforms. You can only paint to a widget (including to an item in a scene rendered by a QGraphicsView widget) during a paint event.

I don't understand your original problem though. Why would you want to paint an item immediately after painting it? The user would not be able to see the first paint because it would happen so fast. Why not just paint the item once? In your mouseReleaseEvent() you can set an appropriate state on the item and call update(). Then in paintEvent() drw the item according to the state you set.

Caius Aérobus
1st April 2009, 18:39
repaint() does not work on all platforms. You can only paint to a widget (including to an item in a scene rendered by a QGraphicsView widget) during a paint event.

I don't understand your original problem though. Why would you want to paint an item immediately after painting it? The user would not be able to see the first paint because it would happen so fast. Why not just paint the item once? In your mouseReleaseEvent() you can set an appropriate state on the item and call update(). Then in paintEvent() drw the item according to the state you set.

That's what I did but the paintEvent() is not processed until I put a window on top of my application window and show it again.

Caius Aérobus
3rd April 2009, 14:59
I have fixed the problem: it is a Mac issue because the same code compiled on Linux works well.