Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Is there a widget to draw a function ?

    QML and Qt Quick
    3
    5
    1029
    Loading More Posts
    • 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.
    • A
      archqt 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

      1 Reply Last reply Reply Quote 0
      • O
        onek24 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 .

        1 Reply Last reply Reply Quote 0
        • A
          archqt last edited by

          Hi,
          Already seen it but thanks for the answer.
          Sincerely

          1 Reply Last reply Reply Quote 0
          • T
            Torgeir 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 = 100

                    var 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).

            1 Reply Last reply Reply Quote 0
            • A
              archqt last edited by

              Hi,
              that what i thought i will have to do it by myself or use qwt.
              Thanks for your answers

              1 Reply Last reply Reply Quote 0
              • First post
                Last post