Qt World Summit: Submit your Presentation

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[])
        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?


Log in to reply