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 find registered qml types from c++ with public api ?
Forum Updated to NodeBB v4.3 + New Features

How to find registered qml types from c++ with public api ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 464 Views 2 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.
  • K Offline
    K Offline
    Kwan
    wrote on last edited by
    #1

    Hi, im writing system monitor like application, for which user can define its layout. From json property i instantiate qml object and set properties for it. I would like to give my users access to built in qml types (rectangle, item and so on).

    1. Is there way to create these qml types from c++ by name?

    2. Also is there way to find all registered qml types ? I'm planning to create simple wysiwyg editor, which would create json for users and i would like to show there qml types also. I know there is private api i can use. But i would be glad if it is posible to make only with public api.

    Ps: I know i could create qml from given json or make user create qml themselves but i dont want to do that.

    raven-worxR 2 Replies Last reply
    0
    • K Kwan

      Hi, im writing system monitor like application, for which user can define its layout. From json property i instantiate qml object and set properties for it. I would like to give my users access to built in qml types (rectangle, item and so on).

      1. Is there way to create these qml types from c++ by name?

      2. Also is there way to find all registered qml types ? I'm planning to create simple wysiwyg editor, which would create json for users and i would like to show there qml types also. I know there is private api i can use. But i would be glad if it is posible to make only with public api.

      Ps: I know i could create qml from given json or make user create qml themselves but i dont want to do that.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Kwan said in How to find registered qml types from c++ with public api ?:

      Is there way to create these qml types from c++ by name?

      not directly.
      But for simple tasks you could do something like that:

      QQmlComponent component(engine);
      component.setData(
      "import QtQuick 2.0" "\n"
      "Rectangle {" "\n"
      "}"
      );
      QQuickItem *rectItem= qobject_cast<QQuickItem*>(component.create());
      QQmlProperty::write(rectItem, "width", QVariant::fromValue<qreal>(100.0));
      QQmlProperty::write(rectItem, "height", QVariant::fromValue<qreal>(50.0));
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • K Kwan

        Hi, im writing system monitor like application, for which user can define its layout. From json property i instantiate qml object and set properties for it. I would like to give my users access to built in qml types (rectangle, item and so on).

        1. Is there way to create these qml types from c++ by name?

        2. Also is there way to find all registered qml types ? I'm planning to create simple wysiwyg editor, which would create json for users and i would like to show there qml types also. I know there is private api i can use. But i would be glad if it is posible to make only with public api.

        Ps: I know i could create qml from given json or make user create qml themselves but i dont want to do that.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @Kwan said in How to find registered qml types from c++ with public api ?:

        Also is there way to find all registered qml types ?

        depends what module you do import.
        You can parse the .qmltypes files (e.g. <QTDIR>/qml/QtQuick.2/plugins.qmltypes) which expose all types the plugin/module provides.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        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