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. Bug? Embedded Menu must be nested in Item.
Forum Update on Monday, May 27th 2025

Bug? Embedded Menu must be nested in Item.

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 731 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.
  • B Offline
    B Offline
    bootchk
    wrote on 14 Dec 2014, 13:31 last edited by
    #1

    Briefly: the documentation says you can use a Quick Controls Menu as a standalone menu, but you actually must nest it inside an Item or another Menu (at least when trying to embed it in a QQuickView.) This seems like a bug, although one that you can workaround.

    I want to embed a QML standalone, popup, context menu in my app. I am trying to create a QuickView on source: "Menu { ... }". It fails, giving:
    file:///home/bootch/Qt/5.4/gcc/qml/QtQuick/Controls/Menu.qml:146: TypeError: Cannot read property '__contentItem' of null
    QQuickView only supports loading of root objects that derive from QQuickItem.

    The error message refers to the Qt source on line 146:

    @/*! \internal */
    property var __parentContentItem: __parentMenu.__contentItem@

    So it seems like Qt code is assuming that the menu has a parent. Which IMO is wrong.

    The workaround is: Item{ Menu { ...}}. But then from the business (C++) side you can't invoke the method popup() on the rootObject of the view, you must know the structure of the object and invoke the method on the child that is a menu.

    No big deal, just something to be aware of.

    1 Reply Last reply
    1

    1/1

    14 Dec 2014, 13:31

    • Login

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