[Interest] Qt 5.3.2 / OSX cannot use native CGContext drawing in paintEvent / Flickering

Nils Heidorn nils_heidorn at gmx.de
Mon Nov 17 22:49:23 CET 2014


Hi List !
I narrowed down my previous Problem about beeing unable to draw exact 
RGB device values...
The core problem is that i cannot really use native (CGContext) drawing 
in Qt5 !
(Where it was working fine in Qt4).

When i show the Qwidget subclass containing my paintEvent there is a 
short flicker where i can see my CGContext drawings ( 2 to three times) 
until finally i can only see a QWidget background. So i know i draw 
things but its somehow not persistent /overwritten.

What i am doing:
---> I create a QWidget subclass and implement a paintEvent method.

Here is a shortened paintEvent method:

void nativePainter::paintEvent(QPaintEvent* e)
{
     QPainter painter;
     painter.begin(this);
     painter.beginNativePainting();
//creating a CGImageRef and put some Bitmap in it
...
//until here
     CGContextRef context = QtMac::currentCGContext();
     CGContextDrawImage(context, cgrect, iref);
     CGContextFlush(context);


//end painting
     painter.endNativePainting();
     painter.end();
}

You can get a full sample that shows the effect here:

http://qt-project.org/forums/viewthread/49751/


Is there someone who can help me out on this one ? Is it a Qt5 Bug ?

Greetings,

Nils




More information about the Interest mailing list