Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Designer not showing components when using a C++ import in QML
Forum Updated to NodeBB v4.3 + New Features

Qt Designer not showing components when using a C++ import in QML

Scheduled Pinned Locked Moved Qt Creator and other tools
qtdesignerqtcreator 3.4.2
5 Posts 4 Posters 4.9k 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.
  • T Offline
    T Offline
    theoribeiro
    wrote on 28 Aug 2015, 14:00 last edited by
    #1

    Hello all,

    When I use a C++ class in QML passing it to context using qmlRegisterType, any components using the registered import get this warning saying that the defined module is not installed.
    This results in these components not being shown in Qt Designer when we are designing their parents.

    This is my current structure:

    main.qml
    |
    |_ MyComponent.qml

    MyComponent uses a C++ registered import and I can edit it using QtDesigner without a problem (apart from the warning message at the topmost item).

    main.qml Cannot be edited using QtDesigner because MyComponent cannot be loaded (with the same warning, module not installed).

    Is this a known issue? Is it possible to work around it without commenting the lines that use the module and the module import?

    Best regards,

    Theo

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ThomasHartmann
      wrote on 19 Oct 2015, 12:19 last edited by
      #2

      What I would do is to mockup the C++ types using a pure QML plugin and creating a .qmlproject file for it.

      Here is an example of a project that contains a pure QML plugin and works in the designer:
      https://github.com/qtproject/qt-creator/tree/master/tests/manual/qml/testprojects/plugins

      The full solution is to move your C++ types into a normal plugin and to make this plugin available to the designer.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bnogal
        wrote on 5 Nov 2015, 16:39 last edited by
        #3

        QtCreator is able to read qmlRegisterTypes calls in source code and add these types to the ones he recognize.

        It is working for me, less in certain cases:

        • One case is when the name or namespace is defined dynamically.
        • When register is done in a implementation of a virtual method.

        I am not completely sure i am right... but that is my case

        I dont know how hard would be to add to QtCreator a function like "permissibe QML types detector" to check in the code for qmlRegisterType<> and match them with the types used in QML code. And inference them (using class name, class name registration, and namespace used)

        it works for me quite well, as it search inside macros, but i am still missing a solution for the second case...

        1 Reply Last reply
        1
        • T Offline
          T Offline
          Thomas Hartmann
          wrote on 24 Nov 2015, 17:36 last edited by
          #4

          While the code model does scan for qmlRegisterType the Qt Quick Designer has to be able to instantiate the real C++ class.
          To be able to do this the C++ class/type has to be moved into a real QML plugin the Qt Quick Designer (qml2puppet) can load.

          B 1 Reply Last reply 26 Nov 2015, 08:41
          0
          • T Thomas Hartmann
            24 Nov 2015, 17:36

            While the code model does scan for qmlRegisterType the Qt Quick Designer has to be able to instantiate the real C++ class.
            To be able to do this the C++ class/type has to be moved into a real QML plugin the Qt Quick Designer (qml2puppet) can load.

            B Offline
            B Offline
            bnogal
            wrote on 26 Nov 2015, 08:41 last edited by
            #5

            @Thomas-Hartmann

            The problem i see is that QtCreator model is too restrictive...

            I just found another problem

            I have a plugin, CustomPluginBase
            And i develop an app that uses this plugin, linking statically so i can extend some types in cpp, and i register new types under namespace "CustomPluginBase.ExtendedTypes"

            Well, QtCreator shows "QML module not found" and as types doesn't exist, even if application works perfectly if i run it. (they get registered)

            I imagine that QtCreator overwrite existing qmlRegisterType in code, with no existing plugin, as base plugin exist.

            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