View Full Version : Subclassing qbutton class

5th October 2006, 20:56
I need to implement a custom button widget class which subclasses qbutton class.
I think that I need to reimplement drawButton method in qbutton class. Can someone tell me how to reimplement drawButton menthod in order to draw a real button on screen?


Jing Bo

5th October 2006, 21:07
Which Qt version do you use? Which button class do you mean? What do you mean by "real button"? In general you need to subclass and reimplement the paintEvent.

5th October 2006, 21:31
I use Qt 3.3.6.

My custom class is like this:

class KIconButton : public QButton

QButton class is an abstract base class, which doesn't draw a button in Qt designer.

So I have to reimplement drawButton method.

The question is What I need to do in drawButton mentod in order for my KIconButton class to be able to draw button in Qt designer.

5th October 2006, 22:15
Well... you should..... draw your button :) Use the QPainter parameter as the painter - use its methods to draw on it.If you have doubts, maybe you should look at the sourcecode of QPushButton.