Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Bug? Embedded Menu must be nested in Item.

$
0
0
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.

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images