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? -
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.
-
So you have a list with two columns:
- Sensor name
- Sensor value
Correct ?
-
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.
-
@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.