View Full Version : add an icon to a pushbutton

25th June 2009, 10:32
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!!

25th June 2009, 10:56

You can look at image-position property in style sheets

Good Luck!

25th June 2009, 10:56
You can't as far as I know. If you use QToolButton, you can set toolButtonStyle to Qt::ToolButtonTextUnderIcon.

25th June 2009, 11:15

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

25th June 2009, 11:29
It is strange that a QToolButton has that function while QPushButton doesn't.
Do you know the difference of them?

25th June 2009, 11:30
Yeah, so do I think.
But I have read the doc, but find no such functions.

25th June 2009, 11:39
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...

25th June 2009, 11:43
Oh, thanks very much!!
But I have one more question: since QToolButton can do whatever QPushButton can, why Qt has QPushButton??

25th June 2009, 11:50
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...