[PyKDE] Problem: drawPushButton

Gerard Vermeulen gvermeul at labs.polycnrs-gre.fr
Wed Jul 11 11:05:39 BST 2001


Greg / Phil

I looked in the qstyle.sip file and I quote:

virtual void drawPushButton(QPushButton *,QPainter *) = 0;
virtual void drawPushButtonLabel(QPushButton *,QPainter *) = 0;

Suppose it means that drawPushButton and drawPushButtonLabel
are pure virtual functions, meaning that you have to redefine
them in a derived class (this is a guess, read on).

Greg, see themes.py in the examples directory how to do this :
def drawButton(self, p, x, y, w, h, g, sunken=FALSE, fill=None)
in the class NorwegianWoodStyle

I looked also in the documentation for pure virtual functions,
but there is none. If my guess is correct, could you add
something to the documentation, Phil?

Another idea is to let calling a pure virtual function generate
a better error message, something like:

drawPushButton is a pure virtual function, it should be
redefined in a class derived from QStyle. (suppose that
sip can easily do that).

Gerard


On Wednesday 11 July 2001 08:41, Grzegorz Zegartowski wrote:
> I've maid some mistakes in last letter.
> Now everything should be ok (I hope)

>
> > Hello
> > I wrote a simple program, and it doesn't work:
> >
> > #############################################################
> > File "test.py", line 12, in drawButton
> >    self.style().drawPushButton(self, painter) #!error
> > AttributeError: drawPushButton
> > #############################################################
> >
> > Any ideas?
>
> ###########################################################################
>######
>
> > ##
> > import sys
> > from qt import *
> >
> > class MyPushButton(QPushButton):
> >    """"""
> >    def __init__(self, parent=None, name=None):
> >        QPushButton.__init__(self, parent, name)
> >      def drawButton(self, painter):
> >        self.style().drawPushButton(self, painter) #!error
> >        self.drawButtonLabel(painter)
> >
> >
> > def main ():
> >    """main"""
> >    app = QApplication(sys.argv)
> >    mybtn = MyPushButton()
> >    mybtn.setText("test")
> >    app.setMainWidget(mybtn)
> >    mybtn.show()
> >    app.exec_loop()
> >
> > if __name__ == '__main__':
> >    main()
>
> ###########################################################################
>##############
>
> > Greg
>





More information about the PyQt mailing list