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. Warnings when creating embedded Menus with Instantiator
Qt 6.11 is out! See what's new in the release blog

Warnings when creating embedded Menus with Instantiator

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 498 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.
  • R Offline
    R Offline
    ribtoks
    wrote on last edited by
    #1

    I'd like to create a Menu in QML application that has other Menus depending on some Model. When I use Instantiator for that, items which are being created are parented to the Instantiator itself and when adding them to top-level Menu, it complains about __parentMenu being null

    Menu {
        title: qsTr("Top-Level Menu")
        id: topMenu
    
        Instantiator {
            model: aTopLevelModel
            onObjectAdded: topMenu.insertItem( index, object )
            onObjectRemoved: topMenu.removeItem( object )
    
            delegate: Menu {
                id: innerMenu
                title: qsTr("Inner Menu")
    
                Instantiator {
                    model: aTopLevelModel.getInnerModel(index)
                    onObjectAdded: innerMenu.insertItem( index, object )
                    onObjectRemoved: innerMenu.removeItem( object )
    
                    delegate: MenuItem {
                        text: qsTr("Menu action!")
                        onTriggered: {
                            console.log("Action of inner menu")
                        }
                    }
                }
            }
        }
    }
    

    The warning I'm observing is: Menu.qml:149: TypeError: Cannot read property '__contentItem' of null

    Where the line 149 is property var __parentContentItem: __parentMenu.__contentItem.

    How can I overcome this Warning being produced?

    Qt version is 5.5.1. This behavior is observed undre OS X and Windows versions of Qt.

    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