Results 1 to 17 of 17

Thread: How to creat different shape of pushbutton?

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

    Default How to creat different shape of pushbutton?

    Hello Friends,
    I want round shaped pushbutton.
    Help me.

    Thanks for help in advance,

    Thank You,
    Manohar

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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?

    What did you try so far?

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

    Default Re: How to creat different shape of pushbutton?

    I used masking to create round shaped buttons .................
    If button is in disabled state, border around button is not continous .......
    I want solution to make border of button to be continues ......

    I hope you got what I have written above ........

    Thank You,
    Manohar

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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?

    What do you mean the border is not continous? Did you reimplement the button's paintEvent?

  5. #5
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to creat different shape of pushbutton?

    If you would use Qt 4.4, you could easily style a button using a stylesheet and the border-radius property to make the corners of your button round.

    Is there any reason why you're staying with Qt3?

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

    Default Re: How to creat different shape of pushbutton?

    Customer Requirement ..........

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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?

    So what about the paintEvent?

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

    Default Re: How to creat different shape of pushbutton?

    I am not getting ...
    If you give some code sample , I will try.

    Thank You,
    Manohar

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.

  10. #10
    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

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.

  12. #12
    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 ...

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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 

  14. #14
    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 ....

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.

  16. #16
    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

  17. #17
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 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, 09: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.