Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. New file fails to register to QML module - how to debug?
Servers for Qt installer are currently down

New file fails to register to QML module - how to debug?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 362 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on 18 Feb 2025, 14:13 last edited by
    #1

    I have added one more to many C++ files that register to a QML module due to be added to the SOURCES of qt_qml_add_module (we're talking cmake here).

    Just like any other of my similar files, it

    • derives from QObject
    • has Q_OBJECT
    • has QML_ELEMENT

    However, this file does not get added to the generated *qmltyperegistrations.cpp files with a "qmlRegisterTypesAndRevisions" entry, like everything else.

    I do not see any warnings during build that could shed light on this. How does one gather more information on why this file specifically does not get registered to qml?

    Obviously, this is not something I can reproduce in a small project - after all, I had >200 files properly registered before this happened for the first time...

    1 Reply Last reply
    0
    • G Online
      G Online
      GrecKo
      Qt Champions 2018
      wrote on 18 Feb 2025, 15:24 last edited by
      #2

      Do additional files also fail to register?
      If you remove one existing file does it still fail?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on 19 Feb 2025, 14:10 last edited by
        #3

        Well, I can play around. But is there

        • no way to enable some kind of tracing for this?
        • no documentation explaining exactly under which circumstances things get added, and when not?
        1 Reply Last reply
        0
        • R Offline
          R Offline
          Redman
          wrote on 20 Feb 2025, 06:50 last edited by
          #4

          Did you make sure to

          target_include_directories(${PROJECT_NAME} PRIVATE
                src/path/to/c++_qml_element
          )
          

          for that file?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on 20 Feb 2025, 08:46 last edited by
            #5

            It was the same for the new file as for all the others.
            But there is a subtle different I did not find documented anywhere:

            You have to

            #include <QQmlEngine>
            

            otherwise it silently fails

            R 1 Reply Last reply 20 Feb 2025, 10:04
            0
            • A Asperamanca has marked this topic as solved on 20 Feb 2025, 08:47
            • A Asperamanca
              20 Feb 2025, 08:46

              It was the same for the new file as for all the others.
              But there is a subtle different I did not find documented anywhere:

              You have to

              #include <QQmlEngine>
              

              otherwise it silently fails

              R Offline
              R Offline
              Redman
              wrote on 20 Feb 2025, 10:04 last edited by
              #6

              @Asperamanca

              #include "qqmlregistration.h"
              

              should suffice and you reduce the header size

              A 1 Reply Last reply 20 Feb 2025, 10:36
              0
              • R Redman
                20 Feb 2025, 10:04

                @Asperamanca

                #include "qqmlregistration.h"
                

                should suffice and you reduce the header size

                A Offline
                A Offline
                Asperamanca
                wrote on 20 Feb 2025, 10:36 last edited by
                #7

                @Redman Thanks, but unfortunately, there is no portable version of this header file available...

                1 Reply Last reply
                0

                1/7

                18 Feb 2025, 14:13

                • Login

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