Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Subclassing QQuickItem and Connections between them
Qt 6.11 is out! See what's new in the release blog

Subclassing QQuickItem and Connections between them

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 530 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.
  • P Offline
    P Offline
    PogoMips2
    wrote on last edited by
    #1

    Hi,

    so I got the following situation, which I don't really know how to solve:

    I got a C++ class that subclasses QQuickItem. And I got another class which provides data for this class to display.

    I thought about connecting both classes with signals and slots so they can exchange control information and data.

    Up until now I only had static data in my QQuickItem subclassed class, so I could make it available in QML via qmlRegisterType. Now that I want to receive dynamic data I encountered the same problem this user had:

    http://qt-project.org/forums/viewthread/744

    He apparently solved it by using setContextProperty(). I also tried this but I can't figure out how to make the object appear on the screen in my Quick Application.

    So up until now it worked like this:
    cpp:
    @qmlRegisterType("Object", 1, 0, "class")@
    qml:
    @import Obejct 1.0
    class { ... }@

    If I do this now via
    cpp:
    @viewer.rootContext()->setContextProperty("Class", &class);@
    it will tell me: class is not a type

    Is there a special way to make QQuickItem subclasses objects known to QML or is this maybe only possible via qmlRegisterType?

    Also if someone has other solutions for that problem I'd be happy to hear them. Thanks.

    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