Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66874

No documentation for managing a dynamically generated list of platform menu items

    XMLWordPrintable

Details

    • e4901286c801162d6b9b94b10d23dafca73c5068

    Description

      A common use case would be a menu containing recent files.

      It's possible to do this with Instantiator:

      import QtQuick 2.7
      import QtQuick.Controls 2.3
      import Qt.labs.platform 1.0 as Platform
      
      ApplicationWindow {
          id: root
          visible: true
          width: 640
          height: 480
      
          property int model: 10
      
          Timer {
              running: true
              repeat: true
              interval: 2000
              onTriggered: {
                  if (model > 1)
                      --model
              }
          }
      
          Platform.MenuBar {
              Platform.Menu {
                  title: "Menu"
      
                  Platform.Menu {
                      id: subMenu
                      title: "Sub-menu"
      
                      Platform.MenuItem {
                          text: "A"
                      }
                      Platform.MenuItem {
                          text: "B"
                      }
                      Instantiator {
                          model: root.model
                          delegate: Platform.MenuItem {
                              text: "C"
                          }
                          onObjectAdded: subMenu.addItem(object)
                          onObjectRemoved: subMenu.removeItem(object)
                      }
                  }
              }
          }
      }
      

      Attachments

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: