[PyQt] Wrapping style classes with SIP for styling
pythonapplication.
Phil Thompson
phil at riverbankcomputing.com
Wed Mar 5 16:56:37 GMT 2008
On Wednesday 05 March 2008, Igor Prischepoff wrote:
> Hello,Phil.
> Attached is my test case with crashing styles
> qtguimod.sip - added 2 lines which include qcommonstyle.sip,qmotifstyle.sip
> qcommonstyle.sip - hand-made wrapper
> qmotifstyle.sip - hand-made wrapper
>
> test_norwegian.py - testing wrapping style which crashes(commenting out
> method polish will fix crash)
>
> test_style.py - testing QStyle abstract style which crashes on _standard_
> pyqt 4.3.3. version
>
> Can you look at what i'm doing wrong here?
>
> p.s.
> Wild guess:
> does qstyle.sip need a
> <%ConvertToTypeCode> section?
You should extend the %ConvertToSubClassCode in qapplication.sip to include
the new classes as they are QObject sub-classes.
> Seems like there is:
> ...
> virtual void polish ( QWidget * widget )
> virtual void polish ( QApplication * application )
> virtual void polish ( QPalette & palette )
> ...
>
> virtual void unpolish ( QWidget * widget )
> virtual void unpolish ( QApplication * application )
> ...
>
> so SIP-level conversion code between QWidget,QApplication and QPalette
> should be there?
> (or maybe i'm totally wrong)
Wrong. If you reimplement polish() in Python then you need to check the type
of the argument to work out overload has been called. Something like...
def polish(self, arg):
if isinstance(arg, QtGui.QPalette):
# polish(const QPalette &) reimplementation
elif isinstance(arg, QtGui.QWidget):
# polish(QWidget *) reimplementation
else:
# We haven't reimplemented this so call the base class.
QMotifStyle.polish(self, arg)
> my environment: windows xp, qt 4.3.3. pyqt 4.3.3-2 opensource,python 2.5
Phil
More information about the PyQt
mailing list