PDA

View Full Version : Adding elements to a QListView



Arreis
30th June 2009, 04:17
Hi, everyone, yet another newbie asking about Qt here. First post, by the way, so nice to meet you all.

I'm trying to make a scrollable list of images, and the best option so far seems to be using a QListView in IconMode. However, no matter how hard I search, I can't find a way to add items to that view. All the examples I've found so far are for Qt version 3.3 and use QListViewItems, which (apparently) no longer exist in Qt 4.5. Since I'm starting, I'm focusing on Qt 4.5: I don't want to get mixed up from the beginning.

Anybody knows how to add elements (specifically images) to a QListView in Qt 4.5? Should I drop the QListView altogether and go for some other option? Thanks in advance for any suggestions.

nish
30th June 2009, 04:43
you have to use delegates in listview.. read about model/view

Arreis
30th June 2009, 05:27
Ehm... thanks for the reply, but, as I said, newbie. Care to share a link, or explain what "model/view" is?

spirit
30th June 2009, 06:10
have a look at this (http://doc.trolltech.com/4.5/model-view-programming.html) and also have a look at Qt's examples QTDIR\examples\itemviews.

Arreis
30th June 2009, 06:56
Thanks! I think I now understand how this works. On to put it to practice!