Results 1 to 3 of 3

Thread: QListView Icons with uniform sizes

  1. #1
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QListView Icons with uniform sizes

    Hi

    I implemented my own model and I'm trying to dislay it with QListView in the Icon mode. I want. The models' DecorationData returns pixmap which is not of the same size for all the items. some are larger, some smaller.

    Now I want them to be laid out on a grid with the same space per item, so I set uniformItemSizes to true.. this resizes all the items to the smallest item size (see the screenshot)

    The I tries setting grid Size to the size of the biggest item, but I cant find a good way to calculate the size for the text below the item, it's sometime quite long. so sometimes the text would get trimmed..

    The i tried to make all the pixmaps returned by the model of the same size by scaling them:
    Qt Code:
    1. return pixmap.scaled(size, Qt::KeepAspectRatio);
    To copy to clipboard, switch view to plain text mode 
    but nothing changed - the size of the smallest icon did not change...

    So basically I tried a few approaches to layout differently sized icons with text on a QListView...Could you please suggest me a solution?

    Thanks
    Attached Images Attached Images

  2. #2
    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 Icons with uniform sizes

    How are you implementing decoration role for the model ?
    You can return uniform size pixmaps from the data function. Since you are using model, you have more control over things.

  3. #3
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QListView Icons with uniform sizes

    yes I use the DecorationRole and that piece of code I had in the initial post is what I return for this role. As you can see Im trying to scale them to the same size but it does not actually scale the pixmaps properly. for example if the pixmap size is 12x80 and I scale it to 80x80 using that code, it still remains 12x80

Similar Threads

  1. Replies: 6
    Last Post: 30th December 2010, 11:19
  2. QT QListView (as icons)
    By Majdi in forum Newbie
    Replies: 10
    Last Post: 2nd March 2010, 23:22
  3. QListView with icons on top of the text, not at the left
    By vfernandez in forum Qt Programming
    Replies: 7
    Last Post: 19th February 2009, 04:19

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.