Results 1 to 4 of 4

Thread: Subclassing qbutton class

  1. #1

    Default Subclassing qbutton class

    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?



    Thanks,

    Jing Bo

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclassing qbutton class

    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.

  3. #3

    Default Re: Subclassing qbutton class

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclassing qbutton class

    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.

Similar Threads

  1. Replies: 2
    Last Post: 4th May 2006, 19:17
  2. How to propagate from one class to another
    By mahe2310 in forum Qt Programming
    Replies: 15
    Last Post: 20th March 2006, 01:27
  3. Replies: 5
    Last Post: 15th March 2006, 07:33
  4. subclassing MainForm class
    By mickey in forum Newbie
    Replies: 19
    Last Post: 6th March 2006, 20:55
  5. Problems with Q_OBJECT and subclassing
    By renaissanz in forum Qt Programming
    Replies: 4
    Last Post: 21st February 2006, 22:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.