Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can't use QtQuick.Controls



  • I can't use QtQuick.Controls.
    I try to import this, and no error when you build it.
    However, when I run this, I get the following error.

    QQmlApplicationEngine failed to load component
    qrc:/qml/main.qml:22:5: ?^ TestRect ?????p????????
    qrc:/qml/TestRect.qml:2:1: "QtQuick.Controls" ???W???[?????C???X?g?[??????????????

    MyCode:
    main.qml

    import QtQuick 2.12
    import QtQuick.Window 2.12
    
    Window {
        id: mainWindow
        width: 640
        height: 480
        visible: true
        title: qsTr("Hellow World")
    
        TestRect{
            id: test
        }
    
    }
    

    TestRect.qml

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    Item {
        Rectangle{
            anchors.top: parent.top
            anchors.left: parent.left
            width: 200
            height: 200
            color: "red"
        }
    }
    

    What is the cause of this?
    I use Qt5.15.2 and windows10


  • Moderators

    @w-tkm have you considered upgrading to at least the latest 5.12 version?



  • @J-Hilk
    No, I haven't considered it because it has been working fine until now.
    Sorry, I made a mistake, it's "5.15.2" to be exact.
    I created a new project with the exact same settings and the exact same code, and it worked.
    Was there a problem with the settings that I missed somewhere?


Log in to reply