I have the following code:
QStringListModel* m=new QStringListModel(gc.get_lista_file());
ui->lista_immagini_listView->setModel(m);
where gc.get_lista_file()
returns a QStringList
object and lista_immagini_listView
is a QListView
.
I need to update my lista_immagini_listView
adding a string when I press a button, but if I add my new string to my QStringList
object it doesn't update my model (I read the QStringList
is passed by copy, so it isn't connected to the model). So, I have to update my QStringListModel
but in this way I have to update 2 object (QStringList
and QStringListModel
) and doesn't seem a good practice.
What is the best way (if exists) to resolve it?