Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set data type in a column
jss193 last edited by
I do not really know if its possible to do what I wish, what I want is to set different data types in a QAbstracItemModel for each column, for example, I want to Column 1 only accepts int values, column2 QString and so on...
Is this possible?
JonB last edited by JonB
You implement that yourself via https://doc.qt.io/qt-5/qabstractitemmodel.html#setData.
If you allow UI editing and want to control the input widget to correspond to the column type, you can use https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForColumn and https://doc.qt.io/qt-5/qabstractitemdelegate.html#createEditor, or https://doc.qt.io/qt-5/qdatawidgetmapper.html#setItemDelegate, to achieve that to match your model column types.
Qt classes do not offer "out-of-the-box" support for column types.