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. Is there a widget to draw a function ?
QtWS25 Last Chance

Is there a widget to draw a function ?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.3k 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.
  • A Offline
    A Offline
    archqt
    wrote on last edited by
    #1

    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
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        archqt
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Torgeir
          wrote on last edited by
          #4

          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
          0
          • A Offline
            A Offline
            archqt
            wrote on last edited by
            #5

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

            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