PDA

View Full Version : QListView with icons on top of the text, not at the left



vfernandez
30th January 2006, 14:44
I'm using QT4 and I would like to have a widget similar to QListView but displaying the icons over the text in each item. It would be something like this:

http://www.deejayworld.net/qt/list-with-icons.png

The screenshot belongs to the configuration dialog of Konqueror. I haven't found any way to put the icons on top, I only get this:

http://www.deejayworld.net/qt/qlistwidget.png

Any idea on how to do that?

yogeshm02
30th January 2006, 15:08
You need to

QListView::setViewMode(QListView::IconMode);
QListView::setFlow (QListView::TopToBottom);

This should work. Though i am not sure, as i only checked the docs, and have not used before.

Everall
30th January 2006, 15:14
have a look at the
Config Dialog Example

This is exactly what you are looking for.

Cheers

vfernandez
30th January 2006, 16:15
Thanks, I already tried setting the view mode to IconMode and this is what I get:

http://www.deejayworld.net/qt/iconmode.png

Probably tweaking the alignment would be ok but I would prefer it to look like this (it's just a mockup):

http://www.deejayworld.net/qt/mockup.png

And then I would adjust the size so that it's not that wide, making it look just like Konqueror and other KDE apps.

yogeshm02
30th January 2006, 16:33
Thanks, I already tried setting the view mode to IconMode and this is what I get: .......


This will get you closer: - :cool:

QListView::setViewMode(QListView::IconMode);
QListView::setFlow (QListView::TopToBottom);
QListView::setWrapping(FALSE);

vfernandez
30th January 2006, 17:45
Great! With setWrapping() it looks much better. I think I'll leave it this way. If I find some way to make the background look like it's selected I'll change it, otherwise I'll leave it like it's now. Thanks!

Ghaleon
18th February 2009, 13:23
I have question closely related to this topic.

Is there way to remove file names from QlistView in iconmode? I have my own listview class derived from QListView. It display thumbnails of certain images. Images will be very clearly self explaining, so those file names will just make UI more unclear.

aamer4yu
19th February 2009, 04:19
Well, if you dont want text at all, you can override data() function of the model, and return empty string (QString()) for Qt::DisplayRole.

If you want changes only in icon mode, best would be to make your own delegate and do nothing in drawDisplay.