Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Make `qt_add_qml_module` generate #include <some_path/file_name.h>
Forum Updated to NodeBB v4.3 + New Features

Make `qt_add_qml_module` generate #include <some_path/file_name.h>

Scheduled Pinned Locked Moved Solved Qt 6
cmake
6 Posts 2 Posters 982 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.
  • D Offline
    D Offline
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h> (where file_name.h is a header containing QML_ELEMENT, for example)?

    If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it? Or even simply include with absolute path?

    IMHO: Adding every directory containing a header with QML_ELEMENT to include path is not a good idea.

    EDIT1:

    C++ files generated with MOC include headers with relative paths like this:

    #include "../../../../MyApp/Purchasing/inapp/inapppurchasebackend.h"
    

    so, it is strange that qt_add_qml_module does not do the same. JSON should contain this relative file name probably, instead of

        "inputFile": "inapppurchasebackend.h",
    

    inputFile is used in qt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar, but I can't figure out at first glance where is it set.

    Christian EhrlicherC D 2 Replies Last reply
    0
    • D Dmitriano

      Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h> (where file_name.h is a header containing QML_ELEMENT, for example)?

      If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it? Or even simply include with absolute path?

      IMHO: Adding every directory containing a header with QML_ELEMENT to include path is not a good idea.

      EDIT1:

      C++ files generated with MOC include headers with relative paths like this:

      #include "../../../../MyApp/Purchasing/inapp/inapppurchasebackend.h"
      

      so, it is strange that qt_add_qml_module does not do the same. JSON should contain this relative file name probably, instead of

          "inputFile": "inapppurchasebackend.h",
      

      inputFile is used in qt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar, but I can't figure out at first glance where is it set.

      D Offline
      D Offline
      Dmitriano
      wrote on last edited by
      #6

      @Dmitriano reported this as a bug.

      1 Reply Last reply
      0
      • D Dmitriano

        Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h> (where file_name.h is a header containing QML_ELEMENT, for example)?

        If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it? Or even simply include with absolute path?

        IMHO: Adding every directory containing a header with QML_ELEMENT to include path is not a good idea.

        EDIT1:

        C++ files generated with MOC include headers with relative paths like this:

        #include "../../../../MyApp/Purchasing/inapp/inapppurchasebackend.h"
        

        so, it is strange that qt_add_qml_module does not do the same. JSON should contain this relative file name probably, instead of

            "inputFile": "inapppurchasebackend.h",
        

        inputFile is used in qt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar, but I can't figure out at first glance where is it set.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Dmitriano said in Make &#x60;qt_add_qml_module&#x60; generate #include <some_path/file_name.h>:

        Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h>

        Not according the documentation.

        If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it?

        Feel free to provide a patch.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          @Dmitriano said in Make &#x60;qt_add_qml_module&#x60; generate #include <some_path/file_name.h>:

          Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h>

          Not according the documentation.

          If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it?

          Feel free to provide a patch.

          D Offline
          D Offline
          Dmitriano
          wrote on last edited by Dmitriano
          #3

          @Christian-Ehrlicher I am not sure, probably the patch is hard for me, but while investigating the sources I found something that is strange enough to be probably reported as a bug, see EDIT1. (while formally it is not a bug of cause)

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            I don't see why this should be a bug. Moc creates a header file which contains a path to it's header it needs. qt_add_qml_module() generates a package so why should there be relative paths to some others which may be different on other machines where you use the package?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            D 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              I don't see why this should be a bug. Moc creates a header file which contains a path to it's header it needs. qt_add_qml_module() generates a package so why should there be relative paths to some others which may be different on other machines where you use the package?

              D Offline
              D Offline
              Dmitriano
              wrote on last edited by Dmitriano
              #5

              @Christian-Ehrlicher My understanding is that both MOC and qt_add_qml_module() generate internal C++ files that are not compiled by others who use the module (or package). Is my understanding correct?

              1 Reply Last reply
              0
              • D Dmitriano

                Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h> (where file_name.h is a header containing QML_ELEMENT, for example)?

                If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it? Or even simply include with absolute path?

                IMHO: Adding every directory containing a header with QML_ELEMENT to include path is not a good idea.

                EDIT1:

                C++ files generated with MOC include headers with relative paths like this:

                #include "../../../../MyApp/Purchasing/inapp/inapppurchasebackend.h"
                

                so, it is strange that qt_add_qml_module does not do the same. JSON should contain this relative file name probably, instead of

                    "inputFile": "inapppurchasebackend.h",
                

                inputFile is used in qt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar, but I can't figure out at first glance where is it set.

                D Offline
                D Offline
                Dmitriano
                wrote on last edited by
                #6

                @Dmitriano reported this as a bug.

                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