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
Forum Update on Monday, May 27th 2025

QAbstractListModel and QCustomPlot

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
16 Posts 4 Posters 569 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.
  • SGaistS SGaist

    Hi,

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

    What exactly is your architecture ?

    T Offline
    T Offline
    Tobias83
    wrote on last edited by
    #3

    @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

    SGaistS 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

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

      What exactly is your architecture ?

      B Offline
      B Offline
      Bob64
      wrote on 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.

      SGaistS 1 Reply Last reply
      0
      • T Tobias83

        @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

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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

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

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          0
          • SGaistS SGaist

            @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 Offline
            B Offline
            Bob64
            wrote on 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
            0
            • B Bob64

              @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 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 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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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
                  0
                  • SGaistS SGaist

                    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 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
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 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
                      0
                      • SGaistS SGaist

                        The XYModelMapper is also there.

                        T Offline
                        T Offline
                        Tobias83
                        wrote on 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
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 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
                          0
                          • SGaistS SGaist

                            Did you change your QML imports as well ?

                            T Offline
                            T Offline
                            Tobias83
                            wrote on last edited by Tobias83
                            #15

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

                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              Did you change your QML imports as well ?

                              T Offline
                              T Offline
                              Tobias83
                              wrote on 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

                              • Login

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