Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtQuick 2 and paint()
Qt 6.12 LTS is out! See what's new in the release blog

QtQuick 2 and paint()

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 894 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.
  • L Offline
    L Offline
    Luckless
    wrote on last edited by Luckless
    #1

    Since QDeclarativeItem got deprecated, we have not been able to find a suitable replacement to use qml and paint() together. Our requirement involves painting custom items in a qml scene. We tried using QSG* but the documentation seems pretty confusing.
    Also let us know how to use QGraphicsItem functions with QtQuick2.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can use QQuickPaintedItem https://doc.qt.io/qt-5/qquickpainteditem.html, it supports QPainter. Using QSG* classes is still a better option, though - for performance.

      (Z(:^

      L 1 Reply Last reply
      2
      • sierdzioS sierdzio

        You can use QQuickPaintedItem https://doc.qt.io/qt-5/qquickpainteditem.html, it supports QPainter. Using QSG* classes is still a better option, though - for performance.

        L Offline
        L Offline
        Luckless
        wrote on last edited by
        #3

        @sierdzio
        We tried using QQuickPaintedItem and its paint function. We also called update whenever any change was made. But the paint function was not being invoked. If there is something that we are missing please tell.
        Also the QQuickPaintedItem documentation quotes "This function, which is usually called by the QML Scene Graph, paints the contents of an item in local coordinates.". I am guessing this means a scene graph is required for using the paint() method.

        sierdzioS 1 Reply Last reply
        0
        • L Luckless

          @sierdzio
          We tried using QQuickPaintedItem and its paint function. We also called update whenever any change was made. But the paint function was not being invoked. If there is something that we are missing please tell.
          Also the QQuickPaintedItem documentation quotes "This function, which is usually called by the QML Scene Graph, paints the contents of an item in local coordinates.". I am guessing this means a scene graph is required for using the paint() method.

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @Luckless said in QtQuick 2 and paint():

          @sierdzio
          We tried using QQuickPaintedItem and its paint function. We also called update whenever any change was made. But the paint function was not being invoked. If there is something that we are missing please tell.

          Make sure you set ItemHasContents flag https://doc.qt.io/qt-5/qquickitem.html#Flag-enum

          Also the QQuickPaintedItem documentation quotes "This function, which is usually called by the QML Scene Graph, paints the contents of an item in local coordinates.". I am guessing this means a scene graph is required for using the paint() method.

          Yes Scene Graph is needed but you don't need to use it. You just pain using QPainter and QML engine does the rest.

          Your application uses QML, right? And this item is part of some QML scene? Or you are using it in some less conventional environment?

          (Z(:^

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved