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. Subclassing QQuickItem
Qt 6.11 is out! See what's new in the release blog

Subclassing QQuickItem

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

    I want to subclass QQuickItem and Create my own Item.

    Currently i have a class that has a QQuickItem which has the following code in the constructor, but i want the class itself to be a QQuickItem
    QQmlComponent component(parent->engine(), QUrl(QStringLiteral("qrc:/Bullet.qml")));
    Item = qobject_cast<QQuickItem*>(component.create());
    Item->setParentItem(parent->rootObject());

    Item is QQuickItem*

    p3c0P 1 Reply Last reply
    0
    • A AhmedYossef

      I want to subclass QQuickItem and Create my own Item.

      Currently i have a class that has a QQuickItem which has the following code in the constructor, but i want the class itself to be a QQuickItem
      QQmlComponent component(parent->engine(), QUrl(QStringLiteral("qrc:/Bullet.qml")));
      Item = qobject_cast<QQuickItem*>(component.create());
      Item->setParentItem(parent->rootObject());

      Item is QQuickItem*

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

      @AhmedYossef Yes you can do that. You will need to re-implement updatePaintNode for the drawing stuff. But be aware that painting in QQuickItem is more complicated. Have a look at this example.

      157

      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