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.
  • ShenCS Offline
    ShenCS Offline
    ShenC
    wrote on 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
    • ShenCS Offline
      ShenCS Offline
      ShenC
      wrote on last edited by
      #2

      Well, is it even possible?

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on 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
        • ShenCS Offline
          ShenCS Offline
          ShenC
          wrote on last edited by ShenC
          #4

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

          1 Reply Last reply
          2

          • Login

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