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. Draw ellipse in Qt5 (porting QPainter functionalities using QSG* classes)

Draw ellipse in Qt5 (porting QPainter functionalities using QSG* classes)

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.1k Views
  • 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.
  • E Offline
    E Offline
    excalibur1491
    wrote on last edited by
    #1

    Hi,

    I did a project with Qt 4.8 and I used QDeclarativeIem and draw circles by using QPainter's drawEllipse method. Now, in Qt5, I really don't seem to find a way to do it. In the porting guide from qt4 to qt5 they say to use the QSG* classes, but I can't find a way to draw ellipses with any of them. I guess the two to look at are: http://qt-project.org/doc/qt-5.0/qtquick/qsgsimplerectnode.html and http://qt-project.org/doc/qt-5.0/qtquick/qsggeometry.html, but there is nothing...

    Any idea? Thanks!

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      Hi, if you just want to port some "old" QPainter stuff you could use "QQuickPaintedItem":http://qt-project.org/doc/qt-5.0/qtquick/qquickpainteditem.html

      If you want to create a custom scene graph item I think this example will help you getting started: https://qt-project.org/doc/qt-5.1/qtquick/scenegraph-customgeometry.html

      1 Reply Last reply
      0
      • E Offline
        E Offline
        excalibur1491
        wrote on last edited by
        #3

        Hi,
        thanks for your fast answer!
        I thought about doing that, but in the doc it says QSG* is much more performant, and since I'll be drawing probably more than a million of those items, I'd rather be as performant as possible.
        What I understand from that example is that it is more of a opengl approach where you place the points and the lines are drawn between them, right? If so, it shouldn't be too hard to draw a circle... (I hope...)

        Thank you!

        1 Reply Last reply
        0
        • X Offline
          X Offline
          Xander84
          wrote on last edited by
          #4

          Well yes as far as I know the complete Qt scene graph is drawn with OpenGL, so the QSG files are just some interface classes for open GL in the end, to abstract open GL a little bit and reuse common stuff like line drawing etc.
          But if you really want to draw 1000 or even millions of the same object you should consider doing a native open GL approach if you care about the best performance, that can also be done with QQuickItem (without using any of the QSG* classes), you just need to override the "paint" method, there are some examples somewhere I think.

          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