The problem is the last line. model->stringList()
returns a copy of the QStringList
used as the model, so you only modify the copy, the one used for the model remains unchanged.
Use something like this:
QStringList list = model->stringList();
list << "d";
model->setStringList(list);
That will work, although setStringList()
will cause a complete, potentially expensive model reset. However, there seems to be no way around that with QStringListModel
.