Insert one text to QListView
Solved
General and Desktop
-
Hi,
I have QListView, QStringListModel, QStringList and QTimer.
When I would like to add one new text to QListView I have to add it to QStringList, set this list in a QStringListModel and set this listModel in QListView.
model->setStringList(list); listView->setModel(model);
It works, but... this is strange for me. Always I have to add all texts to QListView ( always I set model in QListView ). Maybe is a way, where I can add only one new text and still have textes, which I add before? Something like:
listView->addText(newText);
-
QStringListModel has (like every other QAbstractItemModel) the function https://doc.qt.io/qt-5/qstringlistmodel.html#insertRows and https://doc.qt.io/qt-5/qstringlistmodel.html#setData to insert rows and modify the data.