Results 1 to 8 of 8

Thread: QListView with icons on top of the text, not at the left

  1. #1
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QListView with icons on top of the text, not at the left

    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:



    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:



    Any idea on how to do that?

  2. #2
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView with icons on top of the text, not at the left

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView with icons on top of the text, not at the left

    have a look at the
    Config Dialog Example

    This is exactly what you are looking for.

    Cheers

  4. #4
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView with icons on top of the text, not at the left

    Thanks, I already tried setting the view mode to IconMode and this is what I get:



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



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

  5. #5
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView with icons on top of the text, not at the left

    Quote Originally Posted by vfernandez
    Thanks, I already tried setting the view mode to IconMode and this is what I get: .......
    This will get you closer: -

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

  6. #6
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView with icons on top of the text, not at the left

    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!

  7. #7
    Join Date
    Feb 2009
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListView with icons on top of the text, not at the left

    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.

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView with icons on top of the text, not at the left

    Well, if you dont want text at all, you can override data() function of the model, and return empty string (QString()) for Qt:isplayRole.

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

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Window Title Text left alignment issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 3rd March 2010, 14:46
  3. how to get item's text or path from QListVIew
    By Mystical Groovy in forum Qt Programming
    Replies: 4
    Last Post: 5th September 2008, 01:25
  4. [QTabWidget] horizontal text on left side
    By Boy in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2008, 08:52
  5. how to srcoll a long text in one line from right to left?
    By deweyjew in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2006, 10:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.