[PyKDE] class MyStyle(QStyle): pass

Patrick Stinson patrickkidd at gmail.com
Sat Nov 4 23:41:56 GMT 2006

Are you only using paintEvent for your custom widget looks, or have you
every subclassed QStyle? I'm wanting to do some prototyping in python but
I'm getting some odd behavior (like scrollbars not moving) from the
following, which worked fine in c++:

class Style(QStyle):
    def __init__(self, baseStyle):
        self.nativeStyle = QStyleFactory.create(baseStyle)

    def styleHint(self, hint, option, widget, returnData):
        return self.nativeStyle.styleHint(hint, option, widget, returnData)

    def pixelMetric(self, pm, option, widget):
        return self.nativeStyle.pixelMetric(pm, option, widget)

    def drawPrimitive(self, element, option, painter, widget):
        self.nativeStyle.drawPrimitive(element, option, painter, widget)

    def drawControl(self, element, opt, painter,
        self.nativeStyle.drawControl(element, opt, painter, widget)

    def drawComplexControl(self, *args):

    def subElementRect(self, subElement, option, widget):
        return self.nativeStyle.subElementRect(subElement, option, widget)

    def sizeFromContents(self, ct, option, contentsSize, widget):
        return self.nativeStyle.sizeFromContents(ct, option, contentsSize,

    def standardPixmap(self, standardPixmap, option, widget):
        return self.nativeStyle.standardPixmap(standardPixmap, option,

baseName = QApplication.instance().style().objectName()
style = Style(baseName)

Patrick Kidd Stinson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20061105/dfc58df0/attachment.html

More information about the PyQt mailing list