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. QAbstractListModel and QCustomPlot
QtWS25 Last Chance

QAbstractListModel and QCustomPlot

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
16 Posts 4 Posters 539 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.
  • S SGaist
    23 Mar 2025, 12:25

    Hi,

    A model does not have any visual presence. There might be views on top of it though.

    What exactly is your architecture ?

    B Online
    B Online
    Bob64
    wrote on 24 Mar 2025, 09:10 last edited by Bob64
    #4

    @SGaist said in QAbstractListModel and QCustomPlot:

    A model does not have any visual presence.

    I think that's where QCustomPlot comes in. From what I can gather this is an open source add on provided externally to Qt. It seems to be oriented towards QWidgets. There are various discussions in their forum about making it work with QML but QML doesn't appear to be officially supported.

    S 1 Reply Last reply 24 Mar 2025, 19:39
    0
    • T Tobias83
      23 Mar 2025, 22:49

      @SGaist Hello SGaist,

      I load the QAbstractlismodel Hardcoreentrymodel with

      qmlRegisterSingletonInstance("hardcoresystem", 1, 0, "Hardcoreentrymodel", &entryModel);
      

      and then

      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/qt_qml/Main.qml")));
      return app.exec();
      

      in the main function. In Main.qml I import hardcoresystem 1.0

      Or, what do you mean with architecture?

      Tobias

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Mar 2025, 19:33 last edited by
      #5

      @Tobias83 More or less that.

      I wanted to known how you are planning to use that model (or already using) and associate it with widgets or QML components.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Bob64
        24 Mar 2025, 09:10

        @SGaist said in QAbstractListModel and QCustomPlot:

        A model does not have any visual presence.

        I think that's where QCustomPlot comes in. From what I can gather this is an open source add on provided externally to Qt. It seems to be oriented towards QWidgets. There are various discussions in their forum about making it work with QML but QML doesn't appear to be officially supported.

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 24 Mar 2025, 19:39 last edited by
        #6

        @Bob64 said in QAbstractListModel and QCustomPlot:

        @SGaist said in QAbstractListModel and QCustomPlot:

        A model does not have any visual presence.

        I think that's where QCustomPlot comes in. From what I can gather this is an open source add on provided externally to Qt. It seems to be oriented towards QWidgets. There are various discussions in their forum about making it work with QML but QML doesn't appear to be officially supported.

        Not really no but there might be a misunderstanding somewhere.

        So I'll try to clarify:

        • Models only provide data and hints. No widgets (or qml visual components for that matter)
        • You can have widgets handling models such as QListView and friends but they are not part of the model.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply 24 Mar 2025, 22:29
        0
        • S SGaist
          24 Mar 2025, 19:39

          @Bob64 said in QAbstractListModel and QCustomPlot:

          @SGaist said in QAbstractListModel and QCustomPlot:

          A model does not have any visual presence.

          I think that's where QCustomPlot comes in. From what I can gather this is an open source add on provided externally to Qt. It seems to be oriented towards QWidgets. There are various discussions in their forum about making it work with QML but QML doesn't appear to be officially supported.

          Not really no but there might be a misunderstanding somewhere.

          So I'll try to clarify:

          • Models only provide data and hints. No widgets (or qml visual components for that matter)
          • You can have widgets handling models such as QListView and friends but they are not part of the model.
          B Online
          B Online
          Bob64
          wrote on 24 Mar 2025, 22:29 last edited by
          #7

          @SGaist Yes, sorry - you are correct of course. I must admit that I had got more interested in the question about how well QCustomPlot works with QML in the first place. I guess I had assumed that there would be some way to define the plot from a model but you are correct that it is not obvious.

          X 1 Reply Last reply 25 Mar 2025, 11:47
          0
          • B Bob64
            24 Mar 2025, 22:29

            @SGaist Yes, sorry - you are correct of course. I must admit that I had got more interested in the question about how well QCustomPlot works with QML in the first place. I guess I had assumed that there would be some way to define the plot from a model but you are correct that it is not obvious.

            X Offline
            X Offline
            xiliang-mengqi
            wrote on 25 Mar 2025, 11:47 last edited by
            #8

            @Bob64 I am doing same work, but I think it is impossible. Because QcustomPlot depends on QWidgets and event loop, but the QML is other thing. In an app, they , event loop and QML, cann't run at same time. It is pity, but you can find other lib to achieve this function or you can try to recode QCustomPlot by QML which is meanful I think.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Tobias83
              wrote on 25 Mar 2025, 18:17 last edited by
              #9

              OK, I gave up QCustumPlot und found out that there is QtCharts. I wil try with QtCharts and QML.

              Tobias

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 25 Mar 2025, 19:49 last edited by SGaist
                #10

                You should rather go with Qt Graphs. Qt Charts is also graphics view based although QML is also supported and is being deprecated.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                T 1 Reply Last reply 25 Mar 2025, 21:33
                0
                • S SGaist
                  25 Mar 2025, 19:49

                  You should rather go with Qt Graphs. Qt Charts is also graphics view based although QML is also supported and is being deprecated.

                  T Offline
                  T Offline
                  Tobias83
                  wrote on 25 Mar 2025, 21:33 last edited by
                  #11

                  @SGaist Hello SGaist,

                  in QtCharts I can use a model like this

                  ChartView {
                       antialiasing: true
                       anchors.fill: parent
                       legend.visible: false
                       LineSeries {
                           VXYModelMapper {
                           model: Hardcorechartmodelseries
                              xColumn: 0
                              yColumn: 1
                          }
                      }
                  }
                  

                  Is there also this opportunity in QtGraphs?

                  Tobias

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 25 Mar 2025, 21:47 last edited by
                    #12

                    The XYModelMapper is also there.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    T 1 Reply Last reply 26 Mar 2025, 18:42
                    0
                    • S SGaist
                      25 Mar 2025, 21:47

                      The XYModelMapper is also there.

                      T Offline
                      T Offline
                      Tobias83
                      wrote on 26 Mar 2025, 18:42 last edited by
                      #13

                      @SGaist I need also some help with QtGraphs: I changed all the "Charts" to "Graphs" in the cmake file and qml file, and in the QAbstractTableModel. The import QtGraphs prompt in QtCreator recognizes the package, but for this

                      GraphsView {
                        antialiasing: true
                        anchors.fill: parent
                        legend.visible: false
                        LineSeries {
                          VXYModelMapper {
                            model: Hardcorechartmodelseries
                            xColumn: 0
                            yColumn: 1
                          }
                        }
                      }
                      

                      I get a "unkown component" error in QtCreator for the prompts GraphsView, LineSeries and VXYModelMapper

                      I have no idea, what wents wrong. The former QtCharts even drawed some graphs.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 26 Mar 2025, 18:46 last edited by
                        #14

                        Did you change your QML imports as well ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        T 2 Replies Last reply 26 Mar 2025, 20:55
                        0
                        • S SGaist
                          26 Mar 2025, 18:46

                          Did you change your QML imports as well ?

                          T Offline
                          T Offline
                          Tobias83
                          wrote on 26 Mar 2025, 20:55 last edited by Tobias83
                          #15

                          @SGaist Yes, and import QtGraphs is found by QtCreator ...

                          1 Reply Last reply
                          0
                          • S SGaist
                            26 Mar 2025, 18:46

                            Did you change your QML imports as well ?

                            T Offline
                            T Offline
                            Tobias83
                            wrote on 28 Mar 2025, 15:08 last edited by
                            #16

                            @SGaist I made a seperate issue for this problem in the Qt forum:
                            qtcreator-errors-with-qtgraphs-qml

                            Tobias

                            1 Reply Last reply
                            0

                            13/16

                            26 Mar 2025, 18:42

                            • Login

                            • Login or register to search.
                            13 out of 16
                            • First post
                              13/16
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved