Results 1 to 17 of 17

Thread: How to creat different shape of pushbutton?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to creat different shape of pushbutton?

    If you don't tell the button it should paint itself round, you can't expect it to be round. Masking only makes some regions of it transparent, but it won't look good if you just cut holes in a regular push button.

  2. #2
    Join Date
    Mar 2008
    Posts
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to creat different shape of pushbutton?

    I called drawButton() in Widget's paintEvent()
    Following error occurs
    error: ‘virtual void QPushButton::drawButton(QPainter*)’ is protected
    How to resolve it ? Please help me

    Thank You,
    Manohar

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to creat different shape of pushbutton?

    You need to implement your own routine for drawing the button. Are you aware of what I'm telling you or are you just guessing? You need to draw a round button because the button is not round by default, so masking it will not make it round because it's rectangular.

  4. #4
    Join Date
    Mar 2008
    Posts
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to creat different shape of pushbutton?

    Thanks ........
    I am not getting what to write in DrawButton() slot to make round button....
    If you give some hints .... I will try ...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to creat different shape of pushbutton?

    Don't touch DrawButton()! Reimplement paintEvent(). There are lots of examples on how to do that in the docs.
    Qt Code:
    1. void MyClass::paintEvent(QPaintEvent*){
    2. QPainter p(this);
    3. p.drawEllipse(rect());
    4. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Mar 2008
    Posts
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to creat different shape of pushbutton?

    I already reimplement paintEvent() in widget class ....
    Its not working ....

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to creat different shape of pushbutton?

    You must have done it incorrectly then.

  8. #8
    Join Date
    Mar 2008
    Posts
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to creat different shape of pushbutton?

    Please help me to correct that mistake ......

    Thank You,
    Manohar

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to creat different shape of pushbutton?

    Quote Originally Posted by Manohar View Post
    Please help me to correct that mistake ......
    What can we correct? You're not showing anything you've done.
    J-P Nurmi

Similar Threads

  1. shape of a pushbutton
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 16th August 2007, 08:58

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.