Menu in Widget embedded QQuickView

  • I have a QQuickView inside a Window container in a QMainWindow created like this:
    QQuickView* viewer = new QQuickView();
    QWidget* container = createWindowContainer(viewer, this);

    In QML I then create a Menu and onClicked call menu.popup(). I end up with "void QWindow::setTransientParent(QWindow*) QQuickView(0x157afa0) must be a top level window." and the menu showing in the corner of my screen rather than where I clicked.

  • You've provided not enough information. You'd better post the "Minimal Working Example": here.

    I hope "this post": will be useful.

  • As requested
    #include <QApplication>
    #include <QMainWindow>
    #include <QQuickView>

    int main(int argc, char *argv[])
    QApplication app(argc, argv);

    QMainWindow mainWindow;
    QQuickView* viewer = new QQuickView();
    QWidget* container = QWidget::createWindowContainer(viewer, &mainWindow);
    return app.exec();


    import QtQuick 2.2
    import QtQuick.Controls 1.2

    Rectangle {
    width: 1024
    height: 768

    Menu {
        id: menu
        title: "File"
        MenuItem { text: "One"}
        MenuItem { text: "Two"}
        MenuItem { text: "Three"}
    MouseArea {
        anchors.fill: parent
        onClicked: menu.popup()


    void QWindow::setTransientParent(QWindow*) QQuickView(0x6a7270) must be a top level window.

    And menu ends up being placed at what looks like global screen space + offset.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.