Using QAbstractItemModel in Models that haven't any list.
I want to show instant datas like speed,coordinate etc. on ui that I designed with Qml and I want to use model class derived from QAbstractItemModel.
But as I understand it,QAbstractItemModel designed for class that have table,list ... elements.
How can I use it for my design?
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.
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?
So you have a list with two columns:
- Sensor name
- Sensor value
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.
So you have some form of history you want to show ?
I fail to see the use of chart for that then. Do you have a drawing of the UI you want to make ?
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?
You can use it that way. It likely overkill but you can do it.
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.
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.