Results 1 to 5 of 5

Thread: Various icon sizes for QToolButtons on QToolbar

  1. #1
    Join Date
    Nov 2006
    Posts
    29
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default Various icon sizes for QToolButtons on QToolbar

    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.

    Qt Code:
    1. _______________________________________
    2. | ________________ ___ | | | | | | |
    3. | |________________| |___| |
    4. |_______________________________________|
    To copy to clipboard, switch view to plain text mode 

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

    Would this be possible?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Various icon sizes for QToolButtons on QToolbar

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

  3. #3
    Join Date
    Nov 2006
    Posts
    29
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default Re: Various icon sizes for QToolButtons on QToolbar

    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

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Various icon sizes for QToolButtons on QToolbar

    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

  5. The following user says thank you to marcel for this useful post:

    Erlendhg (30th June 2007)

  6. #5
    Join Date
    Nov 2006
    Posts
    29
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default Re: Various icon sizes for QToolButtons on QToolbar

    Yup!
    setFixedSize() seems to be the thing.
    Thanks a lot

Similar Threads

  1. QToolBar icon size
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2007, 13:12
  2. toolbar icon sizes...
    By soul_rebel in forum KDE Forum
    Replies: 2
    Last Post: 20th March 2006, 19:21

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.