Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change menu's icon's size
Qt 6.11 is out! See what's new in the release blog

How to change menu's icon's size

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foxgod
    wrote on last edited by
    #1

    i want to change menu's icon's size to 32*32, how to do it .

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pkj__
      wrote on last edited by
      #2

      If you are using QToolBar, it has a iconSize property. For menu, though, refer "link here":http://www.qtcentre.org/threads/15742-How-to-change-Icon-size-in-QMenu

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        AFAIK QMenu only gets it's icon size from the style it has set.
        So you would need to subclass "QProxyStyle":http://qt-project.org/doc/qt-4.8/qproxystyle.html#details and reimplement pixelMetric() method:

        Something like this:
        @
        class MyProxyStyle : public QProxyStyle
        {
        public:
        int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
        {
        if (metric == QStyle::PM_SmallIconSize)
        return 32;
        else
        return QProxyStyle::pixelMetric(metric, option, widget);
        };
        @
        Haven't tried it though.

        Please also note the hint in the docs:
        [quote]
        Warning: The common styles provided by Qt will respect this hint, because they call QStyle::proxy(), but there is no guarantee that QStyle::proxy() will be called for user defined or system controlled styles. It would not work on a Mac, for example, where menus are handled by the operating system.
        [/quote]

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • F Offline
          F Offline
          foxgod
          wrote on last edited by
          #4

          thank you .i try it

          1 Reply Last reply
          0
          • F Offline
            F Offline
            foxgod
            wrote on last edited by
            #5

            ya,i try your code.it can change icon's size,but when icon's size get big,the QMenu'icon can covered QMenu's text,how to set space
            between icon and text.
            i find a stylesheet's code ,QMenu::item { padding: xx xx xx xx;},it can change space bewteen icon and text. it can use code instead of stylesheet?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved