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. How to make com.mycomponents retrievable by Qt Design Studio?

How to make com.mycomponents retrievable by Qt Design Studio?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 215 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.
  • M Offline
    M Offline
    mynickmynick
    wrote on last edited by
    #1

    I receive an error by Qt Design Studio 3.9.0 after I run my small and simple app. 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 Qt 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 extract:

    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 extract:

    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 help.

    1 Reply Last reply
    0

    • Login

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