Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtCharts future
Qt 6.12 LTS is out! See what's new in the release blog

QtCharts future

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 6 Posters 488 Views 5 Watching
  • 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.
  • PerdrixP Perdrix

    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

    A Offline
    A Offline
    alexiaa
    wrote last edited by
    #2

    @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.

    JKSHJ 1 Reply Last reply
    2
    • A alexiaa

      @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.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote last edited by JKSH
      #3

      @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?

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

      1 Reply Last reply
      2
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote last edited by
        #4

        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/DeepSkyStackerLive

        Yes I guess I could point Claude Code at the files and say "do it", but then I learn nothing :)

        Thanks, David

        JKSHJ 1 Reply Last reply
        0
        • PerdrixP Perdrix

          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/DeepSkyStackerLive

          Yes I guess I could point Claude Code at the files and say "do it", but then I learn nothing :)

          Thanks, David

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote last edited by
          #5

          @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 QChartView with a QQuickWidget that loads a GraphsView instead. The link in my previous post shows exactly how to initialize that QQuickWidget, and shows how to connect your Q*Series classes 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.

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

          1 Reply Last reply
          3
          • Joe von HabsburgJ Offline
            Joe von HabsburgJ Offline
            Joe von Habsburg
            wrote last edited by Joe von Habsburg
            #6

            @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

            1 Reply Last reply
            1
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote last edited by
              #7

              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

              JKSHJ 1 Reply Last reply
              0
              • Joe von HabsburgJ Offline
                Joe von HabsburgJ Offline
                Joe von Habsburg
                wrote last edited by
                #8

                maybe you need, each chart for 1 chartview ?

                1 Reply Last reply
                0
                • PerdrixP Perdrix

                  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

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote last edited by
                  #9

                  @Perdrix said in QtCharts future:

                  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.

                  ... Nor does there seem to be axis related classes and methods e.g.:

                  		xAxis = axisX(qualityChart);
                  

                  The API is not a one-to-one replacement, so you'll need to restructure a few things.

                  Qt Charts uses separate QChartView + QChart classes, but Qt Graphs doesn't have this split. Many equivalents of QChart are found on GraphsView directly (e.g. QChart::axisX() -> QGraphsView::axisX() )

                  So as @Joe-von-Habsburg suggested, perhaps you could maintain multiple QGraphsView objects, and toggle their visible property when you want to show/hide them. With this architecture though, the approach shown at https://doc.qt.io/qt-6/qtgraphs-2d-quickwidgetgraphs-example.html would be unwieldy. It might be worth enabling private API and manipulate the QGraphsView objects directly from C++ (the public QML docs are still useful: https://doc.qt.io/qt-6/qml-qtgraphs-graphsview.html )

                  Alternatively, you could use a separate QQuickWidget per graph.

                  createDefaultAxes()

                  This functionality isn't provided in Qt Graphs, so please create the QValueAxis objects explicitly and set them on the GraphsView object

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

                  1 Reply Last reply
                  2
                  • PerdrixP Offline
                    PerdrixP Offline
                    Perdrix
                    wrote last edited by Perdrix
                    #10

                    @JKSH Oh yuck! That's horrid - how come the guys who designed and built this didn't even consider a relatively normal use case for QtCharts and make sure that code was readily portable. This sounds like it will take weeks of effort to understand and get working :(.

                    More than a bit disappointed.
                    David

                    JKSHJ 1 Reply Last reply
                    0
                    • PerdrixP Perdrix

                      @JKSH Oh yuck! That's horrid - how come the guys who designed and built this didn't even consider a relatively normal use case for QtCharts and make sure that code was readily portable. This sounds like it will take weeks of effort to understand and get working :(.

                      More than a bit disappointed.
                      David

                      JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote last edited by
                      #11

                      @Perdrix I understand the frustration of having to learn new things when your project is already working fine.

                      My suggestion, if you want to proceed, would be to create a standalone "study" project where you implement a simplified version of the graphs from your project. That should help speed up the learning process and help avoid running into dead-ends when editing your actual project.

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

                      1 Reply Last reply
                      1
                      • PerdrixP Offline
                        PerdrixP Offline
                        Perdrix
                        wrote last edited by
                        #12

                        I don't mind learning new stuff - what I very much mind is when the shiny new replacement for the old working stuff doesn't offer a simple migration path for users of the old stuff ...

                        JKSHJ 1 Reply Last reply
                        0
                        • PerdrixP Perdrix

                          I don't mind learning new stuff - what I very much mind is when the shiny new replacement for the old working stuff doesn't offer a simple migration path for users of the old stuff ...

                          JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote last edited by JKSH
                          #13

                          @Perdrix Does it help if you think of the migration like this?:

                          • QChartView -> QQuickWidget
                          • QChart -> QGraphsView

                          Here is also a (QML-centric) migration guide: https://doc.qt.io/qt-6/qtgraphs-migration-guide-2d.html Some parts are outdated/misleading so here is a change request: https://qt-project.atlassian.net/browse/QTBUG-152682

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

                          1 Reply Last reply
                          1
                          • Pl45m4P Online
                            Pl45m4P Online
                            Pl45m4
                            wrote last edited by Pl45m4
                            #14

                            @Perdrix

                            Also keep in mind what @JKSH said in QtCharts future:

                            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.

                            Following the link to DeepSkyStacker repo... I've noticed it's published under

                            [...] the terms of the BSD 3-Clause License (see LICENSE).

                            (https://github.com/deepskystacker/DSS#deepskystacker)

                            I don't want to be a party pooper, but when you use QtGraphs, the whole software / source code cannot be published under BSD3 anymore :/
                            (at least, when the GPL using modules are a mandatory part of the whole software.. otherwise you could offer two options, DSS with modern QtGraphs licensed under GPL and DSS with "old" QtChart or another plotting solution license under BSD-3C.... as always, I'm not a lawyer though )

                            That's the issue with GPL vs. LGPL and one of the QtChart "advantages".

                            From my perspective, there are certain modules in Qt that only make sense to use "professionally", if you have a commercial license. I think QtGraphs is one of them...

                            [Edit: Just realized, QtCharts is also commercial + GPL only, and have always been...]


                            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                            ~E. W. Dijkstra

                            JonBJ 1 Reply Last reply
                            0
                            • Pl45m4P Pl45m4

                              @Perdrix

                              Also keep in mind what @JKSH said in QtCharts future:

                              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.

                              Following the link to DeepSkyStacker repo... I've noticed it's published under

                              [...] the terms of the BSD 3-Clause License (see LICENSE).

                              (https://github.com/deepskystacker/DSS#deepskystacker)

                              I don't want to be a party pooper, but when you use QtGraphs, the whole software / source code cannot be published under BSD3 anymore :/
                              (at least, when the GPL using modules are a mandatory part of the whole software.. otherwise you could offer two options, DSS with modern QtGraphs licensed under GPL and DSS with "old" QtChart or another plotting solution license under BSD-3C.... as always, I'm not a lawyer though )

                              That's the issue with GPL vs. LGPL and one of the QtChart "advantages".

                              From my perspective, there are certain modules in Qt that only make sense to use "professionally", if you have a commercial license. I think QtGraphs is one of them...

                              [Edit: Just realized, QtCharts is also commercial + GPL only, and have always been...]

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote last edited by
                              #15

                              @Pl45m4
                              Indeed, QtGraphs was just the same. I have never used it myself but my first thought would be to try Qwt if you want LGPL or QCustomPlot if you're happy with GPL? For my own part I would not be happy with the new QtGraphs requiring me to bring QML into my widgets application.

                              1 Reply Last reply
                              0
                              • PerdrixP Offline
                                PerdrixP Offline
                                Perdrix
                                wrote last edited by
                                #16

                                I ported the code to qwt given the restrictive nature of the QtGraphs license. Why isn't it LGPL?

                                David

                                Pl45m4P 1 Reply Last reply
                                0
                                • PerdrixP Perdrix has marked this topic as solved
                                • PerdrixP Perdrix

                                  I ported the code to qwt given the restrictive nature of the QtGraphs license. Why isn't it LGPL?

                                  David

                                  Pl45m4P Online
                                  Pl45m4P Online
                                  Pl45m4
                                  wrote last edited by
                                  #17

                                  @Perdrix said in QtCharts future:

                                  given the restrictive nature of the QtGraphs license. Why isn't it LGPL?

                                  Marketing, I guess?! TQtC would like to give you reasons to purchase a commercial license, maybe?!

                                  Some QML and some "new" and "fancy" features are commercial and GPL only.
                                  (e.g. all the 3D / QtQuick stuff, Qt MQTT, Qt Lottie, etc)


                                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                  ~E. W. Dijkstra

                                  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
                                  • Unsolved