PDA

View Full Version : Painting in QCanvasView



JimBrown
11th May 2007, 22:24
I'm trying to learn... I went out and bought the book "C++ GUI Programming with Qt 4" - and then realized that my project at work is in Qt 3. I'm making some mods to the project but upgrading to Qt 4 is not an option.

I'm trying to understand how painting is done in QCanvasView. I'm using a QCanvas that has a bright red background and stores a large (dark) image in a QPixmap. When I have an image loaded, it flickers a lot as you scroll through the CanvasView. I set breakpoints during a repaint, and noticed that QCanvasView first shows the QCanvas background color before it shows the pixmap. Can I get it to stop painting the background color when there is an image loaded?

Thanks a lot,
Jim

wysota
11th May 2007, 22:29
No, but you can use QCanvas::setBackgroundPixmap to set the pixmap as the background. This should prevent the solid background from being drawn. Also try repainting as little as you can (for instance avoid marking the whole canvas as changed).