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 icon size in QMenu's action item?
QtWS25 Last Chance

How to change icon size in QMenu's action item?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 558 Views
  • 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.
  • A Offline
    A Offline
    ahmed.khan
    wrote on 26 Jan 2024, 17:03 last edited by ahmed.khan
    #1

    Hello,

    I've created a QMenu with three actions and set icons to the actions using the setIcon method. The problem is that I am not able to adjust the size of the icons in the QMenu. Is there a way to change it?

    Thanks.

    {Please help me if anyone has any idea about it.}

    C 1 Reply Last reply 26 Jan 2024, 17:20
    0
    • A ahmed.khan
      26 Jan 2024, 17:03

      Hello,

      I've created a QMenu with three actions and set icons to the actions using the setIcon method. The problem is that I am not able to adjust the size of the icons in the QMenu. Is there a way to change it?

      Thanks.

      {Please help me if anyone has any idea about it.}

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 26 Jan 2024, 17:20 last edited by
      #2

      Afaics a menu always has a standard icon size which can not be changed (only by the style via PM_SmallIconSize for all icons) but I also don't see a need for it - I never saw a menu with different icon sizes.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply 26 Jan 2024, 17:26
      0
      • C Christian Ehrlicher
        26 Jan 2024, 17:20

        Afaics a menu always has a standard icon size which can not be changed (only by the style via PM_SmallIconSize for all icons) but I also don't see a need for it - I never saw a menu with different icon sizes.

        A Offline
        A Offline
        ahmed.khan
        wrote on 26 Jan 2024, 17:26 last edited by ahmed.khan
        #3

        @Christian-Ehrlicher, In my use case i am setting up SVG as icons but they don't appear in their actual size.

        Could you please elaborate an example on PM_SmallIconSize or suggest any alternatives?

        I was trying to work around using QMenu's paintEvent but it didn't work either. :(

        C 1 Reply Last reply 26 Jan 2024, 17:43
        0
        • A ahmed.khan
          26 Jan 2024, 17:26

          @Christian-Ehrlicher, In my use case i am setting up SVG as icons but they don't appear in their actual size.

          Could you please elaborate an example on PM_SmallIconSize or suggest any alternatives?

          I was trying to work around using QMenu's paintEvent but it didn't work either. :(

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 26 Jan 2024, 17:43 last edited by
          #4

          @ahmed-khan said in How to change icon size in QMenu's action item?:

          Could you please elaborate an example on PM_SmallIconSize or suggest any alternatives?

          There is no alternative. PM_SmallIconSize is defined by the used style as you can see here: https://doc.qt.io/qt-6/qstyle.html#PixelMetric-enum

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          A 2 Replies Last reply 26 Jan 2024, 18:01
          0
          • C Christian Ehrlicher
            26 Jan 2024, 17:43

            @ahmed-khan said in How to change icon size in QMenu's action item?:

            Could you please elaborate an example on PM_SmallIconSize or suggest any alternatives?

            There is no alternative. PM_SmallIconSize is defined by the used style as you can see here: https://doc.qt.io/qt-6/qstyle.html#PixelMetric-enum

            A Offline
            A Offline
            ahmed.khan
            wrote on 26 Jan 2024, 18:01 last edited by
            #5

            @Christian-Ehrlicher thanks for the help, I will look into it.

            One more question, I'v used QMenu's paintEvent for round corners. The problem is that the resulting round corners are not properly smooth. I've used QRegion and QPainterPath in the paintEvent to set menu's mask using setMask.

            A 1 Reply Last reply 27 Jan 2024, 04:35
            0
            • A ahmed.khan
              26 Jan 2024, 18:01

              @Christian-Ehrlicher thanks for the help, I will look into it.

              One more question, I'v used QMenu's paintEvent for round corners. The problem is that the resulting round corners are not properly smooth. I've used QRegion and QPainterPath in the paintEvent to set menu's mask using setMask.

              A Offline
              A Offline
              ahmed.khan
              wrote on 27 Jan 2024, 04:35 last edited by ahmed.khan
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • C Christian Ehrlicher
                26 Jan 2024, 17:43

                @ahmed-khan said in How to change icon size in QMenu's action item?:

                Could you please elaborate an example on PM_SmallIconSize or suggest any alternatives?

                There is no alternative. PM_SmallIconSize is defined by the used style as you can see here: https://doc.qt.io/qt-6/qstyle.html#PixelMetric-enum

                A Offline
                A Offline
                ahmed.khan
                wrote on 28 Jan 2024, 04:49 last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0

                1/7

                26 Jan 2024, 17:03

                • Login

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