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. QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019
Forum Updated to NodeBB v4.3 + New Features

QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 3 Posters 2.3k Views 2 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.
  • V Offline
    V Offline
    VeNToR
    wrote on last edited by
    #1

    Hi;

    How to use QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019 like Qt Creator ?

    Thanks.

    raven-worxR 1 Reply Last reply
    0
    • V VeNToR

      Hi;

      How to use QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019 like Qt Creator ?

      Thanks.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @VeNToR
      https://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VeNToR
        wrote on last edited by
        #3

        Thanks but this document does not describe good enough (for VC'2019), use qmlRegisterTypesAndRevisions and qmlRegisterModule...

        raven-worxR 1 Reply Last reply
        0
        • V VeNToR

          Thanks but this document does not describe good enough (for VC'2019), use qmlRegisterTypesAndRevisions and qmlRegisterModule...

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @VeNToR
          why is this dependent on the compiler in use?!

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          V 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @VeNToR
            why is this dependent on the compiler in use?!

            V Offline
            V Offline
            VeNToR
            wrote on last edited by
            #5

            @raven-worx
            Because I couldn't find where is the definition of QML_IMPORT_NAME in VC'2019...

            raven-worxR 1 Reply Last reply
            0
            • V VeNToR

              @raven-worx
              Because I couldn't find where is the definition of QML_IMPORT_NAME in VC'2019...

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @VeNToR
              so you are talking about Visual Studio (the IDE) and not the compiler.
              The new qml type registration is only available with qmake so far. (https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qmltyperegistrar/qmltypes.prf)
              Qt6 will introduce support for CMAKE too.
              I dont know about the Visual Studio Qt plugin.

              See the comments in the article

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              V B 2 Replies Last reply
              1
              • raven-worxR raven-worx

                @VeNToR
                so you are talking about Visual Studio (the IDE) and not the compiler.
                The new qml type registration is only available with qmake so far. (https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qmltyperegistrar/qmltypes.prf)
                Qt6 will introduce support for CMAKE too.
                I dont know about the Visual Studio Qt plugin.

                See the comments in the article

                V Offline
                V Offline
                VeNToR
                wrote on last edited by
                #7

                @raven-worx thanks for your time. I am reading now !...

                1 Reply Last reply
                0
                • raven-worxR raven-worx

                  @VeNToR
                  so you are talking about Visual Studio (the IDE) and not the compiler.
                  The new qml type registration is only available with qmake so far. (https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qmltyperegistrar/qmltypes.prf)
                  Qt6 will introduce support for CMAKE too.
                  I dont know about the Visual Studio Qt plugin.

                  See the comments in the article

                  B Offline
                  B Offline
                  barrett9h
                  wrote on last edited by
                  #8

                  @raven-worx said in QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019:

                  The new qml type registration is only available with qmake so far. (https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qmltyperegistrar/qmltypes.prf)
                  Qt6 will introduce support for CMAKE too.

                  Is there a way to get around this? I need to import classes from C++ into QML, I have tested it with qmake (QML_IMPORT_NAME) and it works. But I really wanted to use CMake, because I'm porting an existing project to Qt, and it uses some external libraries with FetchContent.

                  raven-worxR 1 Reply Last reply
                  0
                  • B barrett9h

                    @raven-worx said in QML_NAMED_ELEMENT and QML_IMPORT_NAME in VC'2019:

                    The new qml type registration is only available with qmake so far. (https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qmltyperegistrar/qmltypes.prf)
                    Qt6 will introduce support for CMAKE too.

                    Is there a way to get around this? I need to import classes from C++ into QML, I have tested it with qmake (QML_IMPORT_NAME) and it works. But I really wanted to use CMake, because I'm porting an existing project to Qt, and it uses some external libraries with FetchContent.

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by raven-worx
                    #9

                    @barrett9h
                    sure, you dont need to use those newer macros.
                    See how it's done before those macros were introduced (and is still a valid way AFAIK):
                    https://doc.qt.io/archives/qt-5.9/qqmlextensionplugin.html#plugin-example

                    Basically you need to handle the qml type registration yourself. I personally prefer this way for now, since you are also able to declare multiple import uris which isn't possible with the newer macros (only when you create a separate static lib project and link them together)

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    raven-worxR 1 Reply Last reply
                    0
                    • raven-worxR raven-worx

                      @barrett9h
                      sure, you dont need to use those newer macros.
                      See how it's done before those macros were introduced (and is still a valid way AFAIK):
                      https://doc.qt.io/archives/qt-5.9/qqmlextensionplugin.html#plugin-example

                      Basically you need to handle the qml type registration yourself. I personally prefer this way for now, since you are also able to declare multiple import uris which isn't possible with the newer macros (only when you create a separate static lib project and link them together)

                      raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #10

                      FYI: since Qt 6.2 you can use the qt6_add_qml_module() method in cmake.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      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