Unsolved QAbstractItemModel insert Row Error.
-
Regenerated rowCount function in QAbstractItemModel. At first, Row Count is 0 in QMap.
When you add QPushButton and click this button, InsertRow becomes one line.
However, you can not select or modify these added lines.What should I do? Thank you.
-
@Pada_ said in QAbstractItemModel insert Row Error.:
What should I do?
Explain better and show the relevant code.
Where can't you select/modify the lines? How are you adding them? -
In rowCount (), only the number of returns is selected. If you press the button to insertRow, the line is added on the screen but you can not select or edit it.
If the return value of rowCount is 2, you can select and modify up to 2 lines on the screen first, and nothing will work from the 3rd line added by pressing the button.
-
Hi,
How did you re-implement row count ?
How are you implementing the rows related functions ? -
@Pada_
Have you checked if you have all Qt::Itemflags set:Qt::ItemFlags YourCustomizedModelName::flags(const QModelIndex &index) const { if (index.isValid()) { switch (index.column()) { case 0: { return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; } case 1: { return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; } case 2: // end so on...