Read about Model/View Programming in QtAssistant because you are missing the point. All *View classes are only views for representing some data. This data must be provided by a model. So if you have a view, then you need to create a model which can contain data (like in your case - it can have some QStringList or anything to store data inside) or it can be only interface to data (for example data are in some remote database and model is the thing which communicates with DB and exposes data to view).
In your case you have two solutions:
1. As mentioned - use QListWidget - it is "item based" not "model based" so you don't need any model, you need to add items (QListWidgetItem) to it. And give your data to those items.
2. Another ultra-easy solution :] - use QListView with some model - and there is one model which should done what you want: QStringListModel
Here is the example:
model->setStringList(listing);
ui->ListPic->setModel(model);
QStringList listing;
QStringListModel *model = new QStringListModel(/*some QObject * as a parent, e.g. ui->ListPic */ ui->ListPic);
model->setStringList(listing);
ui->ListPic->setModel(model);
To copy to clipboard, switch view to plain text mode
That's it. But remember to read about Model/View programming to understand clearly how it works. There are many examples and really good description in Assistant.
Bookmarks