PDA

View Full Version : How do disable painting while dragging?



Disperato
26th June 2009, 16:04
Hi,

I'm currently working on a tool that visualizes a map (using Graphics View). Unfortunately, scrolling the map is very slow, as there are lots of Items that have to be repainted.
I thought that maybe I could avoid this. It's not really necessary to repaint the whole scene while moving around on the map. Perhaps I could take a "screen shot", then scroll around, and only repaint the whole scene with all its items when the mouse button is released.

Sadly, I don't know how to implement this idea. How do I tell Qt to refrain from repainting too early/often? How can I tell Qt to render the scene to a "background" that is used while dragging and discarded after the mouse button was released?

Thanks
Daniel

shentian
26th June 2009, 18:47
I would override QGraphicsView::drawItems and suppress drawing the items when you are dragging:


void MyView::drawItems(QPainter* painter, int numItems, QGraphicsItem* items[], const QStyleOptionGraphicsItem options[])
{
if (!dragging)
{
QGraphicsView::drawItems(painter, numItems, items, options);
}
}