I'm porting a Qt 3.3.2 application to Qt 4.1.1
In Qt 3 you can create a QPainter p(&pixmap) and paint to the pixmap anywhere in the code.
In Qt 4 it says that all painting must take place inside the paintEvent.
Why is that the following will work in Qt 4 outside of paintEvent
void someFunc()
{
Pixmap pix(size());
pix.fill(this, 0, 0);
// paint away
}
void someFunc()
{
Pixmap pix(size());
pix.fill(this, 0, 0);
QPainter p(&pix); // no error
// paint away
}
To copy to clipboard, switch view to plain text mode
but, the following will not.
// here ptrPix was filled by another function
void someFunc()
{
QPainter p
(ptrPix
);
// QPainter::begin(), paintdevice returned engine == 0, type: 2 // paint away
}
// here ptrPix was filled by another function
void someFunc()
{
QPainter p(ptrPix); // QPainter::begin(), paintdevice returned engine == 0, type: 2
// paint away
}
To copy to clipboard, switch view to plain text mode
am i missing a concept here?
I will move all of my painting to the paintEvent so that I can take advantage of the double buffering built in to Qt 4, I just want to know what is going on with the above statements.
Thanks.
Bookmarks