PDA

View Full Version : add an icon to a pushbutton



sophister
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!!

zgulser
25th June 2009, 10:56
Hi,

You can look at image-position property in style sheets

Good Luck!

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

zgulser
25th June 2009, 11:15
Hi,

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

sophister
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?
Thanks!!

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

Lykurg
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...

sophister
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??

Lykurg
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...