[SOLVED] QML Dial draw circle
-
Hello,
I want to subclass the QML class Dial like explained here :
http://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-dialUnfortunately, they don't show how to rewrite the method to draw the arc between the Minimum value and the current value like that :
Any idea?
THanks -
Attached image is not found at this moment.
-
@Roumed
Thanks, didn't see that. I reuploaded the screenshot. -
@BlackMamba
I think, the best solution is to use a Canvas and draw your arc with it.
Bad solution is to use Rectangle inside some Item('s) that clip that form of the sector you need and one more Rectangle above to make a ring. -
@Roumed Thank you for your answer. Could you please provide a little more details of the methods to use for the Canvas?
-
@BlackMamba I can give a similar thing.
You can look at PieMenu.
It's background is a half of circle. So it's implementation contains drawing at canvas.
See here: qt/qtquickcontrols/src/extras/Styles/Flat/PieMenuStyle.qml -
@Roumed Thanks so much, I will have a look tonight !
-
Doesn't look so easy. What I don't understand is that the image I showed is the standard Dial behavior in QML.
But when I have a look at the source code and all the files Dial.qml, I don't see the method to draw this circle ... How is that possible? Is that behavior coded in c++ ? -
@BlackMamba
Yes, it is, its ring draws in C++ at qt/qtquickcontrols2/src/imports/controls/qquickdialring.cpp and inserts as background to the control background. -
@Roumed Thanks! I successfully coded it with Canvas thanks to your help.