PDA

View Full Version : Various icon sizes for QToolButtons on QToolbar



Erlendhg
29th June 2007, 16:07
Hi.
Just wondered if it is possible to have QToolButtons on a QToolBar, which has different icon sizes, so that the QToolBars iconSize() doesn't affect the buttons.

Let's say I have a tool button with a icon of size 100x50, and one with 50x50.
Then I want them placed on a QToolBar, so that both icons are showed in their actual size, without needing to have the toolbar to be 100px tall.


_______________________________________
| ________________ ___ | | | | | | |
| |________________| |___| |
|_______________________________________|

(crappy example, I know... :P)
Illustrating the toolbar, and two QToolButtons with icons of different sizes.

Would this be possible?

marcel
29th June 2007, 18:27
About iconSize:


This property holds size of icons in the toolbar. The default size is determined by the application's style and is derived from the QStyle::PM_ToolBarIconSize (http://www.qtcentre.org/forum/qstyle.html#PixelMetric-enum) pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

This means that smaller icons will not influence in any way the behavior.
Only the maximum size matters. It makes icons bigger than that being scaled to iconSize.

So you can just add actions( or whatever ) with all kinds of icon sizes ( but considering that max size restriction ).

Regards

Erlendhg
29th June 2007, 20:36
Yes, but if I enter (100, 50) as the iconSize, all the QToolButtons on that tool bar would be of size 100x50 - even those with icons of 50x50. The icons on 50x50 would just be centered on the buttons.

What I want (if possible), is that one button is 100x50 displaying an icon of size 100x50, and the other buttons beeing 50x50 (not 100x50 too), displaying icons of size 50x50.

That was what I wondered would be possible.

Thanks anyway :)

marcel
29th June 2007, 20:50
Try with QToolbar::addWidget. As parameter pass a QToolbutton with the desired icon set.
If this will not work, try using setFixedSize( pixmapSize ) on the added QToolbutton.

Regards

Erlendhg
30th June 2007, 18:35
Yup!
setFixedSize() seems to be the thing.
Thanks a lot :)