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. Pie Menu Simple Example

Pie Menu Simple Example

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 2.0k 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.
  • V Offline
    V Offline
    vrcomputing
    wrote on last edited by vrcomputing
    #1

    Hi,

    can someone please help me fix this error message:

    Starte C:\Users\Rick\Documents\build-Custom-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug\debug\Custom.exe...
    QML debugging is enabled. Only use this in a safe environment.
    QQmlApplicationEngine failed to load component
    qrc:/main.qml:15 Cannot assign object to list property "menuItems"

    main.qml:

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Window 2.2
    import QtQuick.Extras 1.4
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        PieMenu {
            id: pieMenu
    
            MenuItem {
                text: "Action 1"
                onTriggered: print("Action 1")
            }
            MenuItem {
                text: "Action 2"
                onTriggered: print("Action 2")
            }
            MenuItem {
                text: "Action 3"
                onTriggered: print("Action 3")
            }
        }
    }
    
    

    Examle from: https://doc.qt.io/archives/qt-5.10/qml-qtquick-extras-piemenu.html#populating-the-menu

    Custom.pro:

    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    

    After 2 hours I still couldn't fix it although it is a simple example.

    System: Windows 10 x64, MSVC2017, Qt 5.10.0

    Thank you all and sorry for this beginner question.

    Greetings,

    Rick

    PS: I also tried QML lists ([MenuItem{...}, MenuItem{...}]) and repeaters. Same error message.

    1 Reply Last reply
    0
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by
      #2

      The problem is that MenuItem is member of QtQuick.Controls 1.* module and you are importing QtQuick.control 2.2.

      https://doc.qt.io/archives/qt-5.10/qml-qtquick-controls-menuitem.html

      The below code solve your problem:

      import QtQuick 2.9
      //import QtQuick.Controls 2.2
      import QtQuick.Controls 1.4
      import QtQuick.Window 2.2
      import QtQuick.Extras 1.4
      

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      3

      • Login

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