Results 1 to 3 of 3

Thread: Changing row height

  1. #1
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing row height

    Hi,
    I am trying to change the height of my rows with a custom item delegate.
    I got this, but it doesn't work...

    Qt Code:
    1. QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index)
    2. {
    3. QSize size = QItemDelegate::sizeHint(option, index);
    4. size.setHeight(size.height()+10);
    5. return size;
    6. }
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrong?

    Thanks in advance,
    Gillis

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Changing row height

    * just to be on the safe side: have you (not) set uniformRowHeights() on the view?
    * maybe your model returns some different value in its SizeHintRole?

  3. The following user says thank you to caduel for this useful post:

    supergillis (24th November 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing row height

    I did have uniformRowHeights(true) on the view, but it make any difference after removing. My model didn't return SizeHintRole so that wasn't the problem either. But after adding the SizeHintRole in the model it worked.

    This is what I have now, and it works perfect
    Qt Code:
    1. ...
    2. else if(role == Qt::SizeHintRole)
    3. {
    4. return QSize(0, 20);
    5. }
    6. ...
    To copy to clipboard, switch view to plain text mode 

    Thanks!

Similar Threads

  1. Same height for QComboBox and QPushButton
    By cevou in forum Qt Programming
    Replies: 5
    Last Post: 12th May 2012, 07:56
  2. row height in QTreeView and QTableView
    By yuriry in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 00:58
  3. Qidget height resize if child widgets invisible
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2008, 11:27
  4. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  5. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32

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.