0

I receive an error by Qt Design Studio 3.9.0 after I run my small and simple app, even if the same app runs correctly both on Windows and on an android device simulator, with Qt Creator and/or MS Visual Studio.

I don't understand what am I supposed to add to make com.mycomponents retrievable by Design Studio while it is correctly retrieved when I run the same application with Qt Creator or MS visual Studio

Here's The error I get:

19:38:31: Starting C:\Qt\Tools\QtDesignStudio\qt6_design_studio_reduced_version\bin\qml.exe -I D:/U/Cdev/qt/Romanj/imports -I D:/U/Cdev/qt/Romanj/asset_imports --apptype widget D:/U/Cdev/qt/Romanj/content/App.qml...

QQmlApplicationEngine failed to load component file:///D:/U/Cdev/qt/Romanj/content/App.qml:19:9: Type Screen01 unavailable

file:///D:/U/Cdev/qt/Romanj/content/Screen01.qml:11:1: module "com.mycomponents" is not installed

qml: Did not load any objects, exiting. 19:38:31: C:\Qt\Tools\QtDesignStudio\qt6_design_studio_reduced_version\bin\qml.exe exited with code 2

Here's the C++ code:

int main(int argc, char *argv[])
{
    set_qt_environment();


    QApplication app(argc, argv);
    const QUrl url(u"qrc:Main/main.qml"_qs);
    //REGISTERING C++ TO QML
    qmlRegisterType<MyCppQObject>("com.mycomponents", 1, 0, "MyCppQObject");
    qmlRegisterType<Table>("com.mycomponents", 1, 0, "Table");
    //REGISTERING C++ TO QML
    MyCppQObject myCppQObject("myCppQObjectName");
    Table table("Dictionary");

    engine.rootContext()->setContextProperty("myCppQObject", &myCppQObject);
    engine.rootContext()->setContextProperty("table", &table);

and here is the Screen01.qml file:


import QtQuick 6.2
import QtQuick.Controls 6.2
import UntitledProject1
import com.mycomponents 1.0

Rectangle {
    width: Constants.width
    height: Constants.height
    color: Constants.backgroundColor


    Text { text: currentDateTime }

    TextEdit {//importing C++ remotely defined TableEditor
        text: myCppQObject.name
        anchors.centerIn: parent
        font.family: Constants.largeFont.family
        font.pixelSize: Constants.largeFont.pixelSize
        anchors.verticalCenterOffset: -252
        anchors.horizontalCenterOffset: 0
        onEditingFinished: {myCppQObject.name=text}
    }

    Rectangle {
            x: 50
            y: 100
            width: 100
            height: 100
            color: Constants.backgroundColor

            MyCppQObject{
                id: t
                name:"Pippo"
            }

        TextEdit //importing locally defined TableEditor
        { 
            text: t.name 
            onEditingFinished: {t.name=text}
        }
    }

Perhaps I am using something not supported by Design Studio?

Thanks for the help.

Alessio
  • 1
  • 1

0 Answers0