Results 1 to 18 of 18

Thread: QListView word wrap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    May 2007
    Posts
    10
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QListView word wrap

    Here it is:
    Qt Code:
    1. QSize PartOfSpeechItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
    2. {
    3. QAbstractItemView *view = dynamic_cast<QAbstractItemView*>(parent());
    4. QFontMetrics fontMetrics = view->fontMetrics();
    5. QRect rect = fontMetrics.boundingRect(index.data().toString());
    6. int proportion = (rect.width() / (view->width() + 4));
    7. if (proportion == 0 || rect.width() > view->width())
    8. proportion++;
    9.  
    10. return QSize(view->width() - 4, rect.height() * proportion);
    11. }
    To copy to clipboard, switch view to plain text mode 

    serega.
    Last edited by jacek; 5th August 2007 at 00:42. Reason: changed [html] to [code]

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.