Qt Scene Graph Basic Drawing Example

  • Hi,
    I want to inheritance from QQuickItem and implement updatePaintNode function to draw some basic shapes but I couldn't find a simple way to draw circle,ellipse,arc,... just I found QSGSimpleRectNode that can create a simple rectangle.

    Where is a good and complete tutorial to start with QSG(that explain all classes with examples and also cover the shaders and so on)?

  • Hmmm what's the end point you're actually trying to get to? If your goal is to draw things like ellipses and arcs then it's not obvious diving into QSG is going to help you (there's nothing in QSG which supports drawing those things directly). Possibly QQuickPaintedItem and QPainter would be a better starting point for you (and there's also the option of using the QML Canvas type and doing everything in QML+JS).

  • Dear @timday,
    I just want to have some portable and reusable drawing as a QML component, also performance is really important to me, some special drawing like draw a gauge or some shapes as a independent package as a library which other developers can use them as a QML component.

  • @Alien If I wanted to do something like that I'd probably take a look at the sources of QML components like CircularGauge and Gauge to see how they (and associated styling) are implemented.

    I've found you can do some nice work using the bits of QML which support SVG/bezier curves etc (e.g Image, Canvas) provided you make sure they're only rendered once at the necessary size and then everything subsequently (e.g rotations) is done using HW-accelerated raster operations (all doable from pure QML). But if you ever get into a situation where you're animating the size of something rendering from SVG each render... that's too slow.

  • This post is deleted!

  • @timday ,
    Thanks for your reply,so far as I understand QT doesn't have great documentation on QSG and I have to read the code to get appropriate knowledge about QSG.

    thanks for your help.

  • @Alien That's not what I'm saying. QSG is very well documented; start here. However, there's nothing there which will really help you with drawing ellipses and arcs because that's not what QSG is about. That sort of thing is more the realm of QPainter or QML Canvas.

Log in to reply