Results 1 to 6 of 6

Thread: reimplement QPushButton

  1. #1
    Join Date
    Mar 2012
    Location
    Lesotho
    Posts
    33
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default reimplement QPushButton

    How do i reimplement QPushButton such that its shape is a circle not rectangular

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: reimplement QPushButton

    You should exhaust the possibilities of using style sheets to gain the desired look first. If that cannot do it then subclass QPushButton and re-implement QWidget::paintEvent() to draw the widget however you want. You would also need to provide appropriate size hints.

  3. #3
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: reimplement QPushButton

    Take class AeroButton. Use setRoundness( int roundness ) [0 - rectangle, 99 - oval]
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2012
    Location
    Lesotho
    Posts
    33
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: reimplement QPushButton

    everything seems ok except the size,i did reimplemented sizeHint() but i dont know where to put the call. my widget takes the size of the parent(QPushButton)

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: reimplement QPushButton

    The sizeHint() function will be called by the layout the widget is in (or when the widget is shown for top level widgets). You don't have to call it explicitly.

  6. #6
    Join Date
    Mar 2012
    Location
    Lesotho
    Posts
    33
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: reimplement QPushButton

    Thank you every much.I am aware of that.everything working fine now.

Similar Threads

  1. Reimplement QTreeView
    By wirasto in forum Qt Programming
    Replies: 0
    Last Post: 9th November 2010, 06:11
  2. How to reimplement sizeHint()?
    By Septi in forum Qt Programming
    Replies: 0
    Last Post: 6th July 2010, 13:07
  3. Replies: 0
    Last Post: 22nd February 2010, 09:30
  4. Reimplement of resizeEvent
    By Shawn in forum Qt Programming
    Replies: 20
    Last Post: 27th May 2007, 10:04
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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
  •  
Qt is a trademark of The Qt Company.