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 do you use existing (but not basic) Qml types (for example Rectangle, Buttons, etc.) as properties for custom C++ - defined types?
Forum Updated to NodeBB v4.3 + New Features

How do you use existing (but not basic) Qml types (for example Rectangle, Buttons, etc.) as properties for custom C++ - defined types?

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

    Seems like a stupid question, but I have not found anything about this. There is a page in the documentation that shows how to use custom types as properties for C++ - defined types, but what do I do if I want, for example, a Rectangle as a background for an Item?

    p3c0P 1 Reply Last reply
    0
    • M mahlersand

      Seems like a stupid question, but I have not found anything about this. There is a page in the documentation that shows how to use custom types as properties for C++ - defined types, but what do I do if I want, for example, a Rectangle as a background for an Item?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @mahlersand
      If I understood you correctly, you cant use Rectangle, Buttons directly inside C++ defined types as they don't have a public C++ API's. if you are using QQuickPaintedItem then you can draw your own rectangle using various QPainter methods.

      157

      M 1 Reply Last reply
      1
      • p3c0P p3c0

        Hi @mahlersand
        If I understood you correctly, you cant use Rectangle, Buttons directly inside C++ defined types as they don't have a public C++ API's. if you are using QQuickPaintedItem then you can draw your own rectangle using various QPainter methods.

        M Offline
        M Offline
        mahlersand
        wrote on last edited by
        #3

        @p3c0 Yes, it's just that i wanted to avoid that, as i wanted the Rectangle to be accessible and modifiable from within the QML code. That is currently only (theoretically) possible through the private classes #include <QtQuick/5.5.0/QtQuick/private/qquickrectangle_p.h>, but it is not really working.

        p3c0P 1 Reply Last reply
        0
        • M mahlersand

          @p3c0 Yes, it's just that i wanted to avoid that, as i wanted the Rectangle to be accessible and modifiable from within the QML code. That is currently only (theoretically) possible through the private classes #include <QtQuick/5.5.0/QtQuick/private/qquickrectangle_p.h>, but it is not really working.

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @mahlersand Using private classes is not recommended as its implementation may change from version to version. The best would be to use QQuickPaintedItemand create your own custom types.

          157

          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