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. Using QAbstractItemModel in Models that haven't any list.
Forum Updated to NodeBB v4.3 + New Features

Using QAbstractItemModel in Models that haven't any list.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqabstractmodelmodel-view
12 Posts 3 Posters 1.4k Views 2 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.
  • overlordO Offline
    overlordO Offline
    overlord
    wrote on last edited by
    #3

    There are datas from ethernet include sensor data and gps information. I want to show all sensor datas on a chart and actual gps information on some labels and a map.
    Do you have any suggestion for this scenario?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      So you have a list with two columns:

      • Sensor name
      • Sensor value

      Correct ?

      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
      • overlordO Offline
        overlordO Offline
        overlord
        wrote on last edited by
        #5

        No. I have a one sensor. I want to show all output on a chart,actual(last) gps info(speed,course,time,hdop,pdop etc. on labels and actual(last) coordinate on map. Previous GPS datas will not be stored.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          So you have some form of history you want to show ?

          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
          • overlordO Offline
            overlordO Offline
            overlord
            wrote on last edited by
            #7

            No,I haven't.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              I fail to see the use of chart for that then. Do you have a drawing of the UI you want to make ?

              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
              • overlordO Offline
                overlordO Offline
                overlord
                wrote on last edited by
                #9

                Actually I wonder that can I use QAbstractItemModel for model that generate instant data. So view of that model will show only actual instant data.
                Can I use QAbstractListModel for this purpose.That model have only one row and I will update that row periodically because I want to show only one data at the same time.
                Is this usage correct?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  You can use it that way. It likely overkill but you can do it.

                  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
                  • overlordO Offline
                    overlordO Offline
                    overlord
                    wrote on last edited by
                    #11

                    Or, should I use model derived from QObject and define variable that accessed from qml with Q_PROPERTY.
                    I have never use qml for commercial project before.Therefore I am invastigating proper way to use model/view pattern.

                    JKSHJ 1 Reply Last reply
                    0
                    • overlordO overlord

                      Or, should I use model derived from QObject and define variable that accessed from qml with Q_PROPERTY.
                      I have never use qml for commercial project before.Therefore I am invastigating proper way to use model/view pattern.

                      JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by JKSH
                      #12

                      @overlord said in Using QAbstractItemModel in Models that haven't any list.:

                      I am invastigating proper way to use model/view pattern.

                      The model/view pattern in Qt is designed for cases where you have an arbitrary number of rows of data. Your sensors don't quite match this use-case. Therefore, the model/view pattern is not suitable for your sensors.

                      I suggest you choose the right tool for the job: Just use a data structure for your sensors, like @SGaist suggested.

                      If you want to investigate how to use the model/view pattern, try implementing a model with rows. For example, an address book.

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

                      1 Reply Last reply
                      1

                      • Login

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