Results 1 to 9 of 9

Thread: add an icon to a pushbutton

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question add an icon to a pushbutton

    Hi, I have added an icon to QPushButton, but the icon is always to the left side of text. Is there any way to set to icon on the top on the text??

    Thanks in advance!!

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: add an icon to a pushbutton

    Hi,

    You can look at image-position property in style sheets

    Good Luck!

  3. #3
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: add an icon to a pushbutton

    You can't as far as I know. If you use QToolButton, you can set toolButtonStyle to Qt::ToolButtonTextUnderIcon.

  4. The following user says thank you to shentian for this useful post:

    sophister (25th June 2009)

  5. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: add an icon to a pushbutton

    Hi,

    Since icons are available for push buttons, there should be a way for locating it over the button.

  6. The following user says thank you to zgulser for this useful post:

    sophister (25th June 2009)

  7. #5
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: add an icon to a pushbutton

    It is strange that a QToolButton has that function while QPushButton doesn't.
    Do you know the difference of them?
    Thanks!!

  8. #6
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: add an icon to a pushbutton

    Yeah, so do I think.
    But I have read the doc, but find no such functions.

  9. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: add an icon to a pushbutton

    There is no such function for a QPushButton, because it is not the "aim" of regular button to have an icon above. If you want it above your text use QToolButton as mentioned.
    So since QToolButton offers such a function there is absolutely no need that that is also provided by the QPushButton. Also since a QToolButton can behave exactly like a QPushButton...

  10. #8
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: add an icon to a pushbutton

    Oh, thanks very much!!
    But I have one more question: since QToolButtoncan do whatever QPushButtoncan, why Qt has QPushButton??

  11. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: add an icon to a pushbutton

    Quote Originally Posted by sophister View Post
    why Qt has QPushButton??
    Because it's smaller and therefore has a better performance and it is sufficient for 99,9999% of the purposes/users.
    Or do you use QGraphicsView every time you want to display a simple text or do you use simply a QLabel. So apparently you wont ask why is there a QLabel in Qt...

Similar Threads

  1. QMessageBox missing icon
    By zanth in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2010, 21:20
  2. How to get pushbutton as an icon
    By Pembar in forum Newbie
    Replies: 1
    Last Post: 12th May 2009, 19:59
  3. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 19:03
  4. connecting image to a pushbutton
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 4th December 2007, 09:23
  5. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 10:23

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.