QtCharts future
-
I'm getting the impression that QtCharts is being deprecated. Is there an easy migration path for Widget based C++ applications to some replacement (would that be QtGraphs ?).
I'll certainly not be a happy bunny if I have to rewrite my C++ code as javascript (which I don't use and don't want to use).
Thanks, David
-
I'm getting the impression that QtCharts is being deprecated. Is there an easy migration path for Widget based C++ applications to some replacement (would that be QtGraphs ?).
I'll certainly not be a happy bunny if I have to rewrite my C++ code as javascript (which I don't use and don't want to use).
Thanks, David
@Perdrix said in QtCharts future:
I'm getting the impression that QtCharts is being deprecated. Is there an easy migration path for Widget based C++ applications to some replacement (would that be QtGraphs ?).
I'll certainly not be a happy bunny if I have to rewrite my C++ code as javascript (which I don't use and don't want to use).
Thanks, David
Hi David,
Yes, QtCharts was officially deprecated in Qt 6.10 in favor of QtGraphs, but you do not need to rewrite your code in JavaScript.
If you migrate to QtGraphs, all your chart data and logic stay in C++—you just embed it into your Widgets UI using QQuickWidget along with a minimal, ~10-line declarative QML wrapper file. However, if you want a 100% pure C++ Widgets setup without touching QML at all, the most practical and lightweight alternative is QCustomPlot (just two .h/.cpp files with much better rendering performance), or you can simply stick with QtCharts since it will remain supported throughout the Qt 6 lifecycle.
-
@Perdrix said in QtCharts future:
I'm getting the impression that QtCharts is being deprecated. Is there an easy migration path for Widget based C++ applications to some replacement (would that be QtGraphs ?).
I'll certainly not be a happy bunny if I have to rewrite my C++ code as javascript (which I don't use and don't want to use).
Thanks, David
Hi David,
Yes, QtCharts was officially deprecated in Qt 6.10 in favor of QtGraphs, but you do not need to rewrite your code in JavaScript.
If you migrate to QtGraphs, all your chart data and logic stay in C++—you just embed it into your Widgets UI using QQuickWidget along with a minimal, ~10-line declarative QML wrapper file. However, if you want a 100% pure C++ Widgets setup without touching QML at all, the most practical and lightweight alternative is QCustomPlot (just two .h/.cpp files with much better rendering performance), or you can simply stick with QtCharts since it will remain supported throughout the Qt 6 lifecycle.
@alexiaa said in QtCharts future:
a minimal, ~10-line declarative QML wrapper file
You might not even need a QML wrapper file.
See the official example at https://doc.qt.io/qt-6/qtgraphs-2d-quickwidgetgraphs-example.html
QCustomPlot (just two .h/.cpp files with much better rendering performance)
Do you mean better performance than Qt Charts? Or does it offer better performance than Qt Graphs too?
-
I think I'm being a bit dense here. Let's take a concrete example of a UI tab that implements multiple line charts. The source code is in ChartTab.cpp and ChartTab.h. AFAICT the good news is that a lot of the code in there is to do with manipulation of the many QLineSeries objects. What I don't get is what I have to do to change this code to use QtGraphs. I'm not asking you to do that work, but some pointers of what I need to change would be helpful.
The files in question can be found here:
https://github.com/deepskystacker/DSS/tree/master/DeepSkyStackerLiveYes I guess I could point Claude Code at the files and say "do it", but then I learn nothing :)
Thanks, David
-
I think I'm being a bit dense here. Let's take a concrete example of a UI tab that implements multiple line charts. The source code is in ChartTab.cpp and ChartTab.h. AFAICT the good news is that a lot of the code in there is to do with manipulation of the many QLineSeries objects. What I don't get is what I have to do to change this code to use QtGraphs. I'm not asking you to do that work, but some pointers of what I need to change would be helpful.
The files in question can be found here:
https://github.com/deepskystacker/DSS/tree/master/DeepSkyStackerLiveYes I guess I could point Claude Code at the files and say "do it", but then I learn nothing :)
Thanks, David
@Perdrix said in QtCharts future:
What I don't get is what I have to do to change this code to use QtGraphs.
As @alexiaa alluded to, you must replace
QChartViewwith aQQuickWidgetthat loads aGraphsViewinstead. The link in my previous post shows exactly how to initialize that QQuickWidget, and shows how to connect yourQ*Seriesclasses to the view.P.S. Not related to the port: Both Qt Charts and Graphs are licensed under GPLv3 or Commercial licenses. This means an open-source project that uses either of these modules should also be released under GPLv3.
-
@Perdrix hi, you can use qwt, also if you use qtquick, look at that : https://forum.qt.io/topic/165239/gpu-accelerated-plotting-lib-qaccelplot/2
-
Ok, sort of, I currently have a single QChartView and multiple QChart objects. When I want to show one, I simply call chartView->setChart(QChart*); and the GraphsView doesn't seem to allow selecting which Graph to display.
I don't seem to find an analogue in QGraphs for a QChart object with methods like e.g. createDefaultAxes(). Nor does there seem to be axis related classes and methods e.g.:
xAxis = axisX(qualityChart); xAxis->setRange(1.0, rangeMax); xAxis->setTickAnchor(1.0); xAxis->setTickInterval(interval); yAxis = axisY(qualityChart); if (fQuality > yAxis->max()) yAxis->setMax(fQuality > 0 ? fQuality * 1.1 : fQuality * 0.9); if (fQuality < yAxis->min()) yAxis->setMin(fQuality > 0 ? fQuality * 0.9 : fQuality * 1.1);David
-
maybe you need, each chart for 1 chartview ?