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. non-Q_OBJECT/Q_GADGET based template class registration in QML

non-Q_OBJECT/Q_GADGET based template class registration in QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 824 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.
  • semlanikS Offline
    semlanikS Offline
    semlanik
    wrote on last edited by
    #1

    Hi all,

    I would like to register non-Q_OBJECT/Q_GADGET class in qml. In fact it's template class that wraps int32/64.
    I started investigating arround QQmlValueTypeProvider, but seems didn't make all neccessary registrations.

    Here is code https://git.semlanik.org/semlanik/qtprotobuf/src/dev_semlanik

    This line examples/simplechat/main.qml:125 is trying to assign property of type qtprotobuf::fixed32 and as expected throws:
    qrc:/main.qml:125 Invalid property assignment: unsupported type "qtprotobuf::fixed32"

    What are preconditions for MetaType to be accessible out of QQmlValueTypeProvider?

    Thank you in advance.

    Regards,
    Alexey.

    PS: Yes I know that there are some "public" ways to handle this, but it's on my own to support it in future.

    semlanikS 1 Reply Last reply
    0
    • KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @semlanik As far as I know, only QObject derived classes can be registered to QML => Registering C++ Types with the QML Type System

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      semlanikS 1 Reply Last reply
      0
      • KroMignonK KroMignon

        @semlanik As far as I know, only QObject derived classes can be registered to QML => Registering C++ Types with the QML Type System

        semlanikS Offline
        semlanikS Offline
        semlanik
        wrote on last edited by semlanik
        #3

        @KroMignon, you are partially right, using public API yes, it's only possible to register classes with generated staticMetaObject. But there are hidden ways as always. One of examples QVector3D, I tried to reproduce stuff applied on QVector3D, but it doesn't work for me.

        1 Reply Last reply
        0
        • semlanikS semlanik

          Hi all,

          I would like to register non-Q_OBJECT/Q_GADGET class in qml. In fact it's template class that wraps int32/64.
          I started investigating arround QQmlValueTypeProvider, but seems didn't make all neccessary registrations.

          Here is code https://git.semlanik.org/semlanik/qtprotobuf/src/dev_semlanik

          This line examples/simplechat/main.qml:125 is trying to assign property of type qtprotobuf::fixed32 and as expected throws:
          qrc:/main.qml:125 Invalid property assignment: unsupported type "qtprotobuf::fixed32"

          What are preconditions for MetaType to be accessible out of QQmlValueTypeProvider?

          Thank you in advance.

          Regards,
          Alexey.

          PS: Yes I know that there are some "public" ways to handle this, but it's on my own to support it in future.

          semlanikS Offline
          semlanikS Offline
          semlanik
          wrote on last edited by semlanik
          #4

          @semlanik seems QQmlMetaType::registerCustomStringConverter solved my issue. Will dig deeper into QQmlValueTypeProvider, later.

          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