Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to add an icon for submenu in Quick Controls 2?
QtWS25 Last Chance

How to add an icon for submenu in Quick Controls 2?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlmenu
4 Posts 3 Posters 1.5k 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.
  • N Offline
    N Offline
    nland
    wrote on 9 Jan 2019, 08:08 last edited by nland 1 Sept 2019, 21:52
    #1

    Hi All,

    I'm creating a Windows desktop application with Qt Creator 4.8.0 & Qt 5.12. I have no problem adding an icon for a MenuItem since it has an icon.source property. But how should I achieve the same effect for a submenu?

    A Menu component becomes a submenu when it is defined inside the scope of the upper-level Menu component. And at this time it looks like a MenuItem with an arrow on the right side.

    I have read the Customizing Qt Quick Controls 2 Page but found nothing customizable for this purpose of Menu.

    For Quick Controls1 Menu, there is an iconSource property. But it is removed in Quick Controls 2 Menu. So is there a way to do this?

    0_1547021213600_submenu-icons.png

    With Thanks,
    a qml beginner

    K 1 Reply Last reply 9 Jan 2019, 09:14
    0
    • N nland
      9 Jan 2019, 08:08

      Hi All,

      I'm creating a Windows desktop application with Qt Creator 4.8.0 & Qt 5.12. I have no problem adding an icon for a MenuItem since it has an icon.source property. But how should I achieve the same effect for a submenu?

      A Menu component becomes a submenu when it is defined inside the scope of the upper-level Menu component. And at this time it looks like a MenuItem with an arrow on the right side.

      I have read the Customizing Qt Quick Controls 2 Page but found nothing customizable for this purpose of Menu.

      For Quick Controls1 Menu, there is an iconSource property. But it is removed in Quick Controls 2 Menu. So is there a way to do this?

      0_1547021213600_submenu-icons.png

      With Thanks,
      a qml beginner

      K Offline
      K Offline
      KazuoAsano
      Qt Champions 2018
      wrote on 9 Jan 2019, 09:14 last edited by
      #2

      @nland ,

      I wrote a short Code as below.
      Do you have the same understanding with what my think?

      ApplicationWindow {
          visible: true
      
          menuBar: MenuBar {
            Menu {
              title: qsTr("Sample-MenuBar")
      
              MenuItem {
                text: qsTr("Sample1")
                iconSource: "img/sc01.png"
              }
      
              Menu {
                title: qsTr("Sample2")
                iconSource: "img/sc02.png"
      
                MenuItem {
                  text: qsTr("Sample2-2")
                  iconSource: "img/sc02.png"
                }
              }
            }
          }
      
        // .....
      }
      

      0_1547025225703_sc.png

      N 1 Reply Last reply 9 Jan 2019, 09:17
      0
      • K KazuoAsano
        9 Jan 2019, 09:14

        @nland ,

        I wrote a short Code as below.
        Do you have the same understanding with what my think?

        ApplicationWindow {
            visible: true
        
            menuBar: MenuBar {
              Menu {
                title: qsTr("Sample-MenuBar")
        
                MenuItem {
                  text: qsTr("Sample1")
                  iconSource: "img/sc01.png"
                }
        
                Menu {
                  title: qsTr("Sample2")
                  iconSource: "img/sc02.png"
        
                  MenuItem {
                    text: qsTr("Sample2-2")
                    iconSource: "img/sc02.png"
                  }
                }
              }
            }
        
          // .....
        }
        

        0_1547025225703_sc.png

        N Offline
        N Offline
        nland
        wrote on 9 Jan 2019, 09:17 last edited by nland 1 Sept 2019, 09:24
        #3

        @KazuoAsano Thank you for responding me!

        Yes, I understand your code. But I think you are using Qt Quick Controls 1, which has an iconSource property for Menu component. But in my case, I'm using Quick Controls 2 and for the Menu type, only the title can be specified.

        G 1 Reply Last reply 2 Nov 2019, 15:33
        1
        • N nland
          9 Jan 2019, 09:17

          @KazuoAsano Thank you for responding me!

          Yes, I understand your code. But I think you are using Qt Quick Controls 1, which has an iconSource property for Menu component. But in my case, I'm using Quick Controls 2 and for the Menu type, only the title can be specified.

          G Offline
          G Offline
          gluaxspeed
          wrote on 2 Nov 2019, 15:33 last edited by
          #4

          @nland Did you ever figure this out?

          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