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. Using QML_VALUE_TYPE
Forum Updated to NodeBB v4.3 + New Features

Using QML_VALUE_TYPE

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 269 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by Asperamanca
    #1

    Does anyone know a working example of defining a QML value type in C++ and actually using it in QML?
    The Qt docs only show the C++ part, and none of the Qt Examples (at least in 6.5.2) covers this topic.

    Long story short, I have something like this:

    namespace MyNamespace
    {
    class TestQmlValueType
    {
      Q_GADGET
      QML_VALUE_TYPE(ct_TestQmlValueType)
    public:
      int m_Something;
    };
    } // namespace MyNamespace
    

    This the header is added to a QML module via qt_add_qml_module (SOURCES parameter). The registration for that module is generated as expected (strangely, no mention of my value type, but maybe this is as it should be)

    In a different QML module, I want to use the value type, import the QML module and...can't find it.

    import MyPrefix.MyModule
    
    Rectangle
    {
      id: testRect
      proprerty ct_TestQmlValueType myPropOfCustomValueType // Unknown type
    }
    
    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