[Kde-bindings] Trouble instantiating a QPainter with smoke for Qt 4
Chris Burel
chrisburel at gmail.com
Mon Sep 15 08:08:16 UTC 2008
>> Whenever I try to call QPainter::begin through the smoke library, I
>> always get this error:
>> "QPainter::begin: A paint device can only be painted by one painter at a time."
>> // Doing this works
>> //painter->begin(ptr);
>>
>> // Doing this doesn't
>> methodid = getMethod(qt_Smoke, "QPainter",
>> "begin#");
>> Smoke::StackItem args2[2];
>> smokeCast( qt_Smoke, methodid, args2, 1, ptr,
>> "QPaintDevice" );
>This line smells wrong. The chances of ptr already being a QPaintDevice just seems \
>really low, since there's almost nothing in Qt that returns a QPaintDevice-casted \
>pointer. If it's really a QWidget, I can easily see QPainter::begin() checking for \
>the "am I being painted?" bit at the wrong offset, and seeing it set.
>
>Since painter->begin(ptr) doesn't have a cast in it, I don't think that would compile \
>cleanly given a void*, would it?
>
>- Ashley Winters
Yep, that was it. I guess what this really comes down to is me not
understanding what the difference is between using smoke->cast to get
the ptr to be a qwidget, instead of just doing (QWidget*)ptr.
But since the QPainter method takes a QPaintDevice, but it really
wants a QWidget/QImage/QPixmap etc., how do you get that to work
through the autoload method? Smoke will still say the first argument
to the QPainter instantiation should be cast as a QPaintDevice. I
looked through the qtruby code and didn't see any special cases for
QPainter, but maybe I missed something.
Also, yeah, the "painter->begin(ptr);" was wrong. I must've changed
that between when I tested it and when I posted.
More information about the Kde-bindings
mailing list