[PyQt] Re: QStyle manipulations
phil at riverbankcomputing.com
Mon Jul 27 22:24:58 BST 2009
On Mon, 27 Jul 2009 22:56:57 +0200, "Hans-Peter Jansen" <hpj at urpla.net>
> Am Montag, 27. Juli 2009 schrieb Phil Thompson:
>> On Mon, 27 Jul 2009 21:03:59 +0200, "Hans-Peter Jansen" <hpj at urpla.net>
>> >> const_cast<QStyle
>> >> *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
>> >> d->layoutSpacingIndex, param); return result;
>> >> }
>> >> Do you see any chance of getting this to behave?
>> > Hmm, from what I can see (though I _am_ blind, when it comes to the
>> > guts from sip and PyQt), most of needed mechanics is in place. The
>> > question
>> > what have to be done, that:
>> > * the metaObject is able to locate our method with
>> > metaObject()->indexOfMethod(), and
>> > * qt_metacall is able to invoke our method
>> > The former may already do what it should (otherwise parts of the
>> > QMetaObject
>> > stuff won't do at all, it's even wrapped in qobjectdefs.sip).
>> > The latter seems to be the problem, since it may need some kind of
>> > Parts of qpy/QtCore/qpycore_pyqtproxy.cpp look like they handle
>> > cases. Is it possible to register our method at run-time and be done
>> > with
>> > it, Phil?
>> You can certainly work around the problem with C++ code - but I'm not
>> sure if SIP will allow you to place the C++ code in the right place.
> Hmm, as it stands, I'm lost in a maze of Qt meta object system wrapped in
> the guts of sip and PyQt. It looks like it takes some kind of manual
> registration in the Q*Style constructor on C++ level, which is normally
> covered in the Q_OBJECT macro, but I've no idea, how it all fits together
> conceptually, thus unable to come up with some kind of solution to the
> problem. Will try to solve the problem differently, uglier, much uglier.
> Rarely I regret to be a Python guy, like today :-(.
You may get away with a Python implementation by sub-classing the QStyle
you want to modify and using the pyqtSlot decorator on the method you want
Qt to call.
More information about the PyQt