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?
Forum Updated to NodeBB v4.3 + New Features

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 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
    • GrecKoG Online
      GrecKoG Online
      GrecKo
      Qt Champions 2018
      wrote on 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 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 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 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
            0
            • A Asperamanca has marked this topic as solved on
            • A Asperamanca

              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 last edited by
              #6

              @Asperamanca

              #include "qqmlregistration.h"
              

              should suffice and you reduce the header size

              A 1 Reply Last reply
              0
              • R Redman

                @Asperamanca

                #include "qqmlregistration.h"
                

                should suffice and you reduce the header size

                A Offline
                A Offline
                Asperamanca
                wrote on last edited by
                #7

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

                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