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. How to register a custom QML type in a visual studio project?
Forum Updated to NodeBB v4.3 + New Features

How to register a custom QML type in a visual studio project?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 634 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.
  • S Offline
    S Offline
    ShenC
    wrote on 9 Mar 2022, 05:02 last edited by
    #1

    I'm trying to replicate the code in the tutorial Writing QML Extensions with C++ in a visual studio project (with Qt VS tools extension). But I can not find the correct way to register the newly created QML type.

    Inside the tutorial, it's using qmake code blow to register the QML type:

    CONFIG += qmltypes
    QML_IMPORT_NAME = Charts
    QML_IMPORT_MAJOR_VERSION = 1
    

    But I didn't find the counterpart settings inside the visual studio project settings, and extra qmake commands are not found either. How could I register the type?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      ShenC
      wrote on 9 Mar 2022, 10:44 last edited by
      #2

      Well, is it even possible?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fcarney
        wrote on 9 Mar 2022, 20:38 last edited by
        #3

        The 5.15 way is very inflexible. I don't like it at all.
        https://doc.qt.io/qt-5/qqmlengine.html

        You would do better finding the docs for 5.12 for how to register qml types. It shows how to use qqmlengine better. [https://doc.qt.io/archives/qt-5.12//qtqml-tutorials-extending-qml-example.html(https://doc.qt.io/archives/qt-5.12//qtqml-tutorials-extending-qml-example.html).

        As far as I know the "new way" is not going to replace the "old way".

        We register multiple QML modules that we define. I struggled to see how to do that with the new way.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        1
        • S Offline
          S Offline
          ShenC
          wrote on 10 Mar 2022, 04:48 last edited by ShenC 3 Oct 2022, 05:06
          #4

          It works with the function qmlRegisterType. Literally appreciate your help @fcarney . It had bothered me quite a lot.

          1 Reply Last reply
          2

          1/4

          9 Mar 2022, 05:02

          • Login

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