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. Runtime QML type in Qt Design Studio?
Forum Updated to NodeBB v4.3 + New Features

Runtime QML type in Qt Design Studio?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 651 Views 1 Watching
  • 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.
  • F Offline
    F Offline
    fear2137
    wrote on last edited by
    #1

    In my main.cpp I use qmlRegisterType for my own class and it works when I compile with Qt Creator, however Qt Design Studio cannot read the type I registered, is it possible to make it able to read it?

    KH-219DesignK 1 Reply Last reply
    0
    • F fear2137

      In my main.cpp I use qmlRegisterType for my own class and it works when I compile with Qt Creator, however Qt Design Studio cannot read the type I registered, is it possible to make it able to read it?

      KH-219DesignK Offline
      KH-219DesignK Offline
      KH-219Design
      wrote on last edited by
      #2

      @fear2137 I started typing this answer (below), and I got almost finished answering when I realized that it might not help.

      My answer definitely applies for objects supplied to QML from C++ using QQmlContext::setContextProperty, but I'm actually (I now realize) not at all certain whether it works with objects supplied via qmlRegisterType.

      I'm going to share my answer anyway, because if you didn't know about "dummydata" then this will almost certainly be relevant to you at some point.

      For me, it would still be "homework" or a further investigatory exercise to see whether and how this would help with qmlRegisterType.

      The problem is one that might be solved with "dummydata."

      Caveat: I use qmlscene by launching it directly from a bash terminal prompt. I don't use Qt Design Studio. But I think that both are ultimately using qmlscene under the hood.

      "dummydata" is a folder name that is hardcoded in the source code for qmlscene. You can verify that here:

      • https://github.com/qt/qtdeclarative/blob/1ff2d96d863be027ebed333fb0b441fa051c7cba/tools/qmlscene/main.cpp#L297
      • https://github.com/qt/qtdeclarative/blob/1ff2d96d863be027ebed333fb0b441fa051c7cba/tools/qml/main.cpp#L356

      When qmlscene renders your QML, it will look in the "dummydata" folder and load QML objects that you can name with identical names to what you would otherwise supply in C++.

      Someone in another forum with a similar issue:

      • https://stackoverflow.com/questions/33980010/how-to-preview-qml-documents-referencing-c-types

      Some more info on dummydata: https://doc.qt.io/qt-5/qtquick-qmlscene.html#loading-test-data

      If you also build your own Qt plugin dynamic libraries (using, for example, CONFIG += plugin in qmake *.pro project), then you might need extra arguments to qmlscene so that the QML from your plugin source folder is used. Here is one example of those arguments:

      • https://github.com/219-design/qt-qml-project-template-with-ci/blob/98dc15e143e8/src/lib_app/qml/runscene#L15

      www.219design.com
      Software | Electrical | Mechanical | Product Design

      F 1 Reply Last reply
      0
      • KH-219DesignK KH-219Design

        @fear2137 I started typing this answer (below), and I got almost finished answering when I realized that it might not help.

        My answer definitely applies for objects supplied to QML from C++ using QQmlContext::setContextProperty, but I'm actually (I now realize) not at all certain whether it works with objects supplied via qmlRegisterType.

        I'm going to share my answer anyway, because if you didn't know about "dummydata" then this will almost certainly be relevant to you at some point.

        For me, it would still be "homework" or a further investigatory exercise to see whether and how this would help with qmlRegisterType.

        The problem is one that might be solved with "dummydata."

        Caveat: I use qmlscene by launching it directly from a bash terminal prompt. I don't use Qt Design Studio. But I think that both are ultimately using qmlscene under the hood.

        "dummydata" is a folder name that is hardcoded in the source code for qmlscene. You can verify that here:

        • https://github.com/qt/qtdeclarative/blob/1ff2d96d863be027ebed333fb0b441fa051c7cba/tools/qmlscene/main.cpp#L297
        • https://github.com/qt/qtdeclarative/blob/1ff2d96d863be027ebed333fb0b441fa051c7cba/tools/qml/main.cpp#L356

        When qmlscene renders your QML, it will look in the "dummydata" folder and load QML objects that you can name with identical names to what you would otherwise supply in C++.

        Someone in another forum with a similar issue:

        • https://stackoverflow.com/questions/33980010/how-to-preview-qml-documents-referencing-c-types

        Some more info on dummydata: https://doc.qt.io/qt-5/qtquick-qmlscene.html#loading-test-data

        If you also build your own Qt plugin dynamic libraries (using, for example, CONFIG += plugin in qmake *.pro project), then you might need extra arguments to qmlscene so that the QML from your plugin source folder is used. Here is one example of those arguments:

        • https://github.com/219-design/qt-qml-project-template-with-ci/blob/98dc15e143e8/src/lib_app/qml/runscene#L15
        F Offline
        F Offline
        fear2137
        wrote on last edited by
        #3

        @KH-219Design I have created my own plugin, and it is recognized by Qt Design Studio QML editor but when I run the app it gives me Cannot load library: The specified module could not be found error

        KH-219DesignK 1 Reply Last reply
        0
        • F fear2137

          @KH-219Design I have created my own plugin, and it is recognized by Qt Design Studio QML editor but when I run the app it gives me Cannot load library: The specified module could not be found error

          KH-219DesignK Offline
          KH-219DesignK Offline
          KH-219Design
          wrote on last edited by
          #4

          @fear2137 Based on some superficial searching I just did, it seems that "The specified module could not be found." and the corresponding code ERROR_MOD_NOT_FOUND are specific to Qt on Microsoft Windows, and that is the platform that I spend the least time with, so (combined with the fact that I don't use Design Studio) I probably can't help further. Hopefully someone else will know.

          Based on similar issues I have seen, I would hypothesize that both of the following might be worth investigating:

          1. is it possible to put your own plugin "somewhere" where it will be found at launch (I am sure you are trying this already), but also...
          2. Consider the possibility that Qt is finding your plugin, but that subsequently Qt is unable to locate further dll files that your plugin transitively depends on.

          That option (2) has caught me by surprise in the past. Option (2) also seems to be suggested by these:

          • https://stackoverflow.com/questions/62013190/qt-plugin-loading-fails-specified-module-could-not-be-found
          • https://stackoverflow.com/questions/67906646/matlab-engine-in-qt-c-specified-module-could-not-be-found

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          F 1 Reply Last reply
          0
          • KH-219DesignK KH-219Design

            @fear2137 Based on some superficial searching I just did, it seems that "The specified module could not be found." and the corresponding code ERROR_MOD_NOT_FOUND are specific to Qt on Microsoft Windows, and that is the platform that I spend the least time with, so (combined with the fact that I don't use Design Studio) I probably can't help further. Hopefully someone else will know.

            Based on similar issues I have seen, I would hypothesize that both of the following might be worth investigating:

            1. is it possible to put your own plugin "somewhere" where it will be found at launch (I am sure you are trying this already), but also...
            2. Consider the possibility that Qt is finding your plugin, but that subsequently Qt is unable to locate further dll files that your plugin transitively depends on.

            That option (2) has caught me by surprise in the past. Option (2) also seems to be suggested by these:

            • https://stackoverflow.com/questions/62013190/qt-plugin-loading-fails-specified-module-could-not-be-found
            • https://stackoverflow.com/questions/67906646/matlab-engine-in-qt-c-specified-module-could-not-be-found
            F Offline
            F Offline
            fear2137
            wrote on last edited by
            #5

            @KH-219Design I did a hack by turning the dll name into exe and ran windeployqt to copy all needed modules, I then copied everything to the module folder in project but still error remains.

            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