Results 1 to 2 of 2

Thread: QListWidget shrink to fit size of items

  1. #1
    Join Date
    Mar 2010
    Posts
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListWidget shrink to fit size of items

    Hi there

    I've got a problem with QListWidget. I'd like to have the widget to shrink to the smallest size vertically. It shoud show all contained items.

    I tried to achieve this with the sizePolicy and spacers. But I didn't get what i
    I want.

    QListWidgetToFitSize.png

    I the picture you see what I have on the first list and what I'd like to have on the second list.

    Thanks for your help!

    Luke
    Using Qt 4.7
    Developping on Win 7 and XP
    Using Qt Creator, Eclipse and Visual Studio
    Target Platforms Win, Linux and soon OS X

  2. #2
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListWidget shrink to fit size of items

    you could use
    while (verticalScrollBar()->pageStep() <= count() ) resize(w,h+X);

    or

    resize(w,itemHeight*count()+offset)

Similar Threads

  1. How to iterate through QListWidget items
    By zero-n in forum Newbie
    Replies: 6
    Last Post: 13th January 2012, 10:09
  2. Shrink QMainWindow to Minimum Size
    By kloffy in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2008, 17:54
  3. Replies: 2
    Last Post: 11th September 2007, 08:57
  4. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  5. Getting all items of a QListWidget
    By Codepoet in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2006, 22:52

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.