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. Equivalent of CONFIG+=qmltypes in CMake build?
Qt 6.11 is out! See what's new in the release blog

Equivalent of CONFIG+=qmltypes in CMake build?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.5k 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hello.
    I just found out about the new way to expose C++ types to QML using the
    QML_ELEMENT macro, as described e.g. here.

    To test it with CMake builds, I converted the Adding example
    Qt/Examples/Qt-5.15.0/qml/referenceexamples/adding
    to a CMake project.

    While it runs fine when using the old way of registering the type with

    qmlRegisterType<Person>("People", 1,0, "Person");
    

    it fails when commenting that line out (and uncommenting the QML_ELEMENT macro):

    QQmlComponent: Component is not ready
    (qrc:example.qml:52:1: module "People" is not installed
        import People 1.0
        ^)
    

    I assume it has to do with not having used the CMake equivalent of the following .pro line:

    CONFIG+=qmltypes
    

    But, what is the CMake equivalent of the above CONFIG flag?

    Thanks for your help!

    DiracsbracketD 1 Reply Last reply
    3
    • DiracsbracketD Diracsbracket

      Hello.
      I just found out about the new way to expose C++ types to QML using the
      QML_ELEMENT macro, as described e.g. here.

      To test it with CMake builds, I converted the Adding example
      Qt/Examples/Qt-5.15.0/qml/referenceexamples/adding
      to a CMake project.

      While it runs fine when using the old way of registering the type with

      qmlRegisterType<Person>("People", 1,0, "Person");
      

      it fails when commenting that line out (and uncommenting the QML_ELEMENT macro):

      QQmlComponent: Component is not ready
      (qrc:example.qml:52:1: module "People" is not installed
          import People 1.0
          ^)
      

      I assume it has to do with not having used the CMake equivalent of the following .pro line:

      CONFIG+=qmltypes
      

      But, what is the CMake equivalent of the above CONFIG flag?

      Thanks for your help!

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by Diracsbracket
      #2

      @gillamkid, @Seboo
      It seems CONFIG+=qmltypes is not supported in CMake for Qt 5 versions, but can be used in Qt 6, as described here:
      https://stackoverflow.com/questions/63509161/how-to-use-qml-element-with-cmake

      Have not tested it though.

      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