On Thursday 08 July 2004 13:45, Vicent Mas wrote:
> Hi,
> I'm trying to create a simple custom style (newbie with styles) but I
> cannot to make it work, so I need some help. This is what I've done.
>
> customstyle script
> -------------------------
> from qt import *
>
> class CustomStyle(QWindowsStyle):
>       def __init__(self) :
>               apply(QWindowsStyle.__init__m (self,))
>
>       def drawControl(self, celem, painter, widget, rect, colorGroup, flags,
> opt) : print "I'm here"
>               if celem ==QStyle.CE_PushButtonLabel :
>                       # do something
>               else :
>                       QWindowsStyle(self, celem, painter, widget, rect, colorGroup, 
> flags,
> opt)
>
> main script:
> ----------------
> from customstyle import *
> ...
> app = QApplication(args)
> app.setStyle(customStyle())
> ...
>
> I expected that when the application draws the label (pixmap or iconset
> with text) of any QPushButton some actions would be executed, but nothing
> happens. In fact the string <I'm here> is never printed.
> I really don't know what is wrong. Please, could you tell me where are the
> mistakes?

Works for me - once all the syntax errors in the above fragment are fixed (and 
the incorrect call to the QWindowsStyle ctor is replaced by a call to 
QWindows.drawControl()).

It's always better to post a complete script - like the attached.

Phil

Attachment: style.py
Description: application/python

Reply via email to