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. Auto-wrapping non-QObject types when passing to QML
Forum Updated to NodeBB v4.3 + New Features

Auto-wrapping non-QObject types when passing to QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 342 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.
  • I Offline
    I Offline
    Igor Baidiuk
    wrote on last edited by
    #1

    Hello!

    Is it possible to automatically convert between two non-QObject user-defined types (one is C++-friendly, other is QML-friendly) when passing them to/from QML, similar to how QVector, QList etc. are wrapped and unwrapped as Array-like JavaScript objects?

    Thanks,
    Igor

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckielwein
      wrote on last edited by
      #2

      I am 99% sure this is not possible.

      For a type to be usable in QML it's members, how to access them, etc. needs to be made available to the QML engine.
      This happens through the QT Meta Object System.

      To provide some C++ data or functionality to QML, it must be made available from a QObject-derived class.

      https://doc.qt.io/qt-5/qtqml-cppintegration-overview.html

      You could probably implement a set of macros which combine conventions of your codbase with QT macros to create wrapper types around your types which also derive from QObject.

      1 Reply Last reply
      2
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        Have you looked at this page?

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        1

        • Login

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