Results 1 to 3 of 3

Thread: QTableView row height via delegate and setRootIndex

  1. #1
    Join Date
    Jan 2007
    Location
    Hamburg, Germany
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTableView row height via delegate and setRootIndex

    Hi,

    I have a QTableView with a delegate, this sets the row height of the table view, via override sizeHint:

    Qt Code:
    1. QSize MyClass::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. QSize s = QItemDelegate::sizeHint(option, index);
    4.  
    5. if ( s.isValid() )
    6. s.setHeight(20);
    7.  
    8. return s;
    9. }
    To copy to clipboard, switch view to plain text mode 

    This works 100%. But if I set a new root index for the tableview:

    Qt Code:
    1. void QAbstractItemView::setRootIndex ( const QModelIndex & index )
    To copy to clipboard, switch view to plain text mode 

    the row height is set to default height. The delegate is ignored! I need a fixed row height, also after a new root index!


    Does anyone know, what the problem is? How can I fix this?

    Thanks!
    Chris
    Last edited by pmaktieh.sirhc; 16th January 2007 at 20:59.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView row height via delegate and setRootIndex

    Could you post a minimal compilable example reproducing the problem?

  3. #3
    Join Date
    Jan 2007
    Location
    Hamburg, Germany
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView row height via delegate and setRootIndex

    I've found my mistake, I must call

    Qt Code:
    1. void QTableView::resizeRowsToContents()
    To copy to clipboard, switch view to plain text mode 

    after the new index has set!

    ...nevertheless thanks for your help!

    Chris

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.