Results 1 to 3 of 3

Thread: How to make QListWidget to have enough size to show all items?

  1. #1
    Join Date
    Aug 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to make QListWidget to have enough size to show all items?

    Hello! I have a QListWidget in icon mode, it is also set to wrap its items.
    In constructor of parent widget, I populate QListWidget with serveral items so they wrap to second line (and possibly third, fourth, etc).
    With this scenario vertical scrollbar gets added to my QLW, while I want to somehow resize it to the size allowing to see all items at once - w/o scrollbars (I do have free space for that, so don't worry )

    How can I achive this? I have tried to write 'qlw->resize( qlw->sizeHint() )' after populating 'qlw' with items, but this doesn't help.

    Of course I can always use 'setFixedHeight()' with precalculated height, but my app is run on several OS's and maintaining different precalculated heights for each of them is a PITA .

    Any hints, guys?
    Thanks in advance!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make QListWidget to have enough size to show all items?

    use resize(viewport()->sizeHint());

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make QListWidget to have enough size to show all items?

    Hmm... it returns QSize(-1,-1).

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  2. Get Visible Items from the QListWidget
    By srj in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:13
  3. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  4. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04

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.