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

simple import of registered extended C++ type not working



  • I'm trying to an extend QML with C++, similar to this tutorial. I create my C++ class Surface3DExtension and register it with uri "MyTest.test" in main.cpp:

    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
        // Register extended type
        qmlRegisterExtendedType<Q3DSurface, Surface3DExtension>("MyTest.test", 1, 0, "QSurface3D");
    

    I have an import statement for "MyTest.test" in main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.3
    import QtDataVisualization 1.2
    import MyTest.test 1.0
    

    But when viewing main.qml in qtcreator editor, an error message appears next to the import statement:

    QML module not found (MyTest.test)
    

    All files for my project are in the same directory. Why can't the extension module be found?

    Thanks


Log in to reply