Results 1 to 8 of 8

Thread: How to Modify QListView item height?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: How to Modify QListView item height?

    Just new a QListView in an Object. I wonder why setSpacing(...) function doesn't work..

    Quote Originally Posted by aamer4yu View Post
    How are you using QLIstView ?
    If you are using model, you need to return size hint from the data() function of the model.

    something like
    if(role == Qt::sizeHintRole)
    return QSize(width,height);

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

    Default Re: How to Modify QListView item height?

    Can you show us some code of what u are doing ?
    hard to say whats wrong without seeing more

  3. #3
    Join Date
    Jan 2012
    Location
    St. Petersburg, Russia
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Wiki edits
    1

    Default Re: How to Modify QListView item height?

    Try this in the last resort:

    Qt Code:
    1. QListView listView;
    2. listView->setStyleSheet("QListView::item { height: 100px; }");
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Sep 2011
    Location
    Portugal
    Posts
    25
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanked 5 Times in 5 Posts

    Default Re: How to Modify QListView item height?

    If you're using a delegate, try to override the sizeHint method.

    Header:
    Qt Code:
    1. QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
    To copy to clipboard, switch view to plain text mode 

    Source:
    Qt Code:
    1. QSize MyDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
    2. {
    3. return(QSize(100, 50));
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. how to modify menu item height
    By blackfox in forum Qt Programming
    Replies: 2
    Last Post: 9th September 2008, 11:02
  2. how to move item up and down in QListView
    By zhanglr in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2008, 15:39
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 08:37
  4. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 04:13

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
  •  
Qt is a trademark of The Qt Company.