Results 1 to 6 of 6

Thread: How to change the size of icons in the menus of the menu bar ?

  1. #1
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    3
    Qt products
    Qt Jambi
    Platforms
    Unix/X11

    Default How to change the size of icons in the menus of the menu bar ?

    I can't find a way to change the size of icons in the actions associated with the menus (like New,Open,etc.) I can change the font size of the text associated with the action but not the icon size. I am actually using Jambi but I can easily manipulate Qt's functions to fit on Jambi.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How to change the size of icons in the menus of the menu bar ?

    http://doc.qt.nokia.com/4.7/qstyleop...xIconWidth-var

    But, be aware that some styles might not use it to get the icon size.

  3. #3
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    3
    Qt products
    Qt Jambi
    Platforms
    Unix/X11

    Default Re: How to change the size of icons in the menus of the menu bar ?

    Thanks. But the menu class doesn't seem to have any option to set it to an object of QStyleOptionMenuItem. I think the setStyle option might work but QStyleOptionMenuItem is not a style but aids in the style, but I can't understand how to implement it. Can u give a small code that sets the menu's icon width using this class ?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How to change the size of icons in the menus of the menu bar ?


  5. #5
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    3
    Qt products
    Qt Jambi
    Platforms
    Unix/X11

    Default Re: How to change the size of icons in the menus of the menu bar ?

    Thanks. I did this :

    1. Created a QProxyStyle object.
    2. Created a QStyleOptionMenuItem object called o. Called the function setMaxIconWidth (24)
    3. Called the drawControl function called oo. Parameters were CE.MenuBarItem, o and a new QPainter object.
    4. Called the menu's setStyle function with oo.

    Nothing changed. I wonder that the setMaxIconWidth only sets the maximum width. The fact that I want to increase the size of icons is not getting conveyed by this method, i think.

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How to change the size of icons in the menus of the menu bar ?

    The size of the icon is measured by its width. It is a rectangle. Example: 20x20. The minimum size in some of the styles is 20, so you can't go smaller. But the maximum size is taken from the maximum icon width of the option you set.

    I do not have time at the moment, but I'll try to create an example later today (evening on my part of the world). But I can't promise anything.

    Note that styles don't need to follow special guidelines. This means that a technique that works with one style, might not work with another. This in turn means that it would be a good idea to create a custom menu style, which you can also do with the proxystyle

Similar Threads

  1. Missing Icons for Menu and Toolbar
    By LostInTheWoods in forum Qt Tools
    Replies: 1
    Last Post: 8th January 2010, 11:42
  2. no icons in menu
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2009, 20:09
  3. Replies: 2
    Last Post: 27th June 2008, 19:02
  4. Suppressing menu icons on the Mac
    By Brandybuck in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 19:00
  5. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 19:16

Tags for this Thread

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.