On Friday 12 December 2008, Witteveen, Arnt wrote:
> 
> Hi, I'm looking to implement something like firefox's list of downloaded
> items: a scrollable list (mine will also allow rearaanging by drag and
> drop) of items, where the items are a little more than an icon and some
> text (e.g., a big icon, a few lines of text, a link you can click and
> maybe even a button). 
> 
> QListView looks like just what I need, except that I don't see any way
> to override what is drawn per item. Is there any way to do that? If not,
> should I derive from QListView, or direve from one of it's parent
> classes (but that would mean re-implementing some of Qlistviews features
> in my class, I guess?)

The recommended way to do any extensive customization of items is to create a
custom delegate and set it on a QListView widget. For simple datasets, you
could use a QStandardItemModel object to hold the information about the
items.

See "An Introduction to Model/View Programming" to get started:

  http://doc.trolltech.com/4.4/model-view-introduction.html

> I've looked at QListWidget/QListWidgetItem. I would think I could create
> a QListWidget with items derived from QListWidgetItem, but I don't see
> how to override the look of a QListWidgetItem either. And the docs for
> those recommend using QListView instead, so I keep thinking that if I
> would be able to do it with I QListWidgetItems, I should be able to do
> the same with QListWidget?

QListWidgetItem isn't designed to be customized extensively. You may get
better results if you create a QItemDelegate subclass for use with QListView
and customize that instead.

Good luck!

David
-- 
David Boddie
Senior Technical Writer
Nokia, Qt Software
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to