How to do graph with QML
-
wrote on 19 May 2013, 08:35 last edited by
How to do graph with QML
-
wrote on 19 May 2013, 10:08 last edited by
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.
-
wrote on 19 May 2013, 10:43 last edited by
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.
-
wrote on 19 May 2013, 12:23 last edited by
Can you give me the example ?
-
wrote on 19 May 2013, 12:51 last edited by
http://qt-project.org/doc/qt-5.0/qtquick/customitems-painteditem.html
http://qt-project.org/doc/qt-5.0/qtquick/canvas.htmlSadly, the documentation for this examples still seems to be broken, but you can see how its done in the files.
-
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.htmlEdit: 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
-
wrote on 21 May 2013, 01:08 last edited by
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. -
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
-
wrote on 13 Dec 2014, 04:08 last edited by
-
wrote on 13 Dec 2014, 04:08 last edited by
-
wrote on 14 Jan 2015, 14:10 last edited by
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 -
wrote on 14 Jan 2015, 14:10 last edited by
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