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.5k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 12 Aug 2019, 18:18 last edited by SGaist 8 Dec 2019, 21:44
    #2

    Hi,

    From the looks of it, it seems you rather want a QObject based class with various Q_PROPERTY for the values you want to show.

    In any case, you should give more details about the data source and what you plan 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
    • O Offline
      O Offline
      overlord
      wrote on 12 Aug 2019, 18:32 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 12 Aug 2019, 18:36 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
        • O Offline
          O Offline
          overlord
          wrote on 12 Aug 2019, 19:41 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Aug 2019, 20:05 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
            • O Offline
              O Offline
              overlord
              wrote on 12 Aug 2019, 20:18 last edited by
              #7

              No,I haven't.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 12 Aug 2019, 20:37 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
                • O Offline
                  O Offline
                  overlord
                  wrote on 12 Aug 2019, 20:49 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
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 12 Aug 2019, 21:04 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
                    • O Offline
                      O Offline
                      overlord
                      wrote on 12 Aug 2019, 21:15 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.

                      J 1 Reply Last reply 12 Aug 2019, 21:48
                      0
                      • O overlord
                        12 Aug 2019, 21:15

                        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.

                        J Offline
                        J Offline
                        JKSH
                        Moderators
                        wrote on 12 Aug 2019, 21:48 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

                        11/12

                        12 Aug 2019, 21:15

                        • Login

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