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. How to do graph with QML
QtWS25 Last Chance

How to do graph with QML

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 6 Posters 14.4k 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.
  • J Offline
    J Offline
    Jens
    wrote on last edited by
    #2

    Qt 5 comes with a "Canvas":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-canvas.html element where you can do simple painting, similar to html 5.

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on last edited by
      #3

      You can just as well use a custom QQuickPaintedItem with QPainter painting on top of it. I generally find QPainter easier to work with than the canvas, probably because I've used QPainter far more.

      The canvas element was created to target HTML5 developers, so the API is modeled after the html canvas rather than QPainter, which IMO is the better drawing API.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jjew.isaraporn
        wrote on last edited by
        #4

        Can you give me the example ?

        1 Reply Last reply
        0
        • U Offline
          U Offline
          utcenter
          wrote on last edited by
          #5

          http://qt-project.org/doc/qt-5.0/qtquick/customitems-painteditem.html
          http://qt-project.org/doc/qt-5.0/qtquick/canvas.html

          Sadly, the documentation for this examples still seems to be broken, but you can see how its done in the files.

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #6

            Here are the fixed versions:
            http://doc-snapshot.qt-project.org/qt5-stable/qtquick/customitems-painteditem.html
            http://doc-snapshot.qt-project.org/qt5-stable/qtquick/canvas.html

            Edit: You can use "Qwt":http://qwt.sourceforge.net/ widgets to draw graphs in C++, but there is nothing similar in QML yet. You need to write your own graphing code -- read points, and then draw lines between the points

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • C Offline
              C Offline
              chrisadams
              wrote on last edited by
              #7

              See https://qt.gitorious.org/qt/qtdeclarative/trees/stable/examples/quick/demos/stocqt for the StocQt example which uses the canvas to paint graphs and do other interesting things.

              Cheers,
              Chris.

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #8

                Great example, Chris! I forgot about that.

                You can find a screenshot at http://doc-snapshot.qt-project.org/qt5-stable/qtquick/demos-stocqt.html . The chart code is in StockChart.qml

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mehrdad
                  wrote on last edited by
                  #9

                  here it is...
                  http://jwintz.me/blog/2014/02/15/qchart-dot-js-qml-binding-for-chart-dot-js/

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mehrdad
                    wrote on last edited by
                    #10

                    here it is...
                    http://jwintz.me/blog/2014/02/15/qchart-dot-js-qml-binding-for-chart-dot-js/

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mehrdad
                      wrote on last edited by
                      #11

                      but this is a bit complex
                      this is a good runable example that help me very much...
                      i hope help you too
                      https://github.com/shuirna/QMLChartJs

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mehrdad
                        wrote on last edited by
                        #12

                        but this is a bit complex
                        this is a good runable example that help me very much...
                        i hope help you too
                        https://github.com/shuirna/QMLChartJs

                        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