tags:

views:

31

answers:

1

How to save QListView items to text file?

+1  A: 

Access the elements via the underlying Item Model and write them to the file in whatever way makes sense in the context of your program.


EDIT for more detail:

I'm a little rusty in my Qt experience right now, so I don't have an exact snippet of code. Furthermore, there's probably more than one way to go about doing this.

Every Qt View is attached to an associated model derived from QAbstractItemModel. (If you don't know how that Model/View stuff works, they you ought to read over some of their documentation, such as here.)

Generally, I would expect the derived model class to have some convenient functions for getting at the data. For instance, QStringListModel has a member for getting the data as a QStringList. So the easiest way to get the data depends on the actual model class being used in your particular application.

Otherwise, you could ask the the view for its model through model() and then ask that for each piece of data through data().

TheUndeadFish
Can you provide piece of code how to get QListView items to QStringList?
TermiT
Edited to add more detail about that.
TheUndeadFish