Is there a widget to draw a function ?
-
wrote on 22 May 2014, 12:11 last edited by
Hi,
for example i would like to Draw sinus(x) from 0 to 2PI (in QML if possible or QWidgets). Is there something already done ? (i prefer to ask before doing the thing).
Thanks -
wrote on 22 May 2014, 12:52 last edited by
Hello,
i don't know of an existing component for your purposes, but you might check out this "thread":http://qt-project.org/forums/viewthread/8998 .
-
wrote on 22 May 2014, 13:39 last edited by
Hi,
Already seen it but thanks for the answer.
Sincerely -
wrote on 22 May 2014, 13:42 last edited by
For a simple plot of a function a Canvas may suffice:
@Canvas {
width: 300
height: 200
onPaint: {
var numSamples = 300
var amplitude = 100var ctx = getContext("2d") ctx.beginPath() for (var i = 0; i < numSamples; ++i) ctx.lineTo(i, amplitude + Math.sin(2 * Math.PI * i / numSamples) * amplitude) ctx.stroke() } }
@
If you need complex scientific plots, have a look at Qwt. Using Qwt in a QQuickPaintedItem looks fairly straight forward. I googled and found an example "here":http://vadim-d.blogspot.no/2013/07/qml-qwt-android.html (the blog post is in russian, but the code is in english).
-
wrote on 22 May 2014, 16:06 last edited by
Hi,
that what i thought i will have to do it by myself or use qwt.
Thanks for your answers
5/5