Results 1 to 2 of 2

Thread: RichText Delegate and size hint for row height

  1. #1
    Join Date
    Nov 2010
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default RichText Delegate and size hint for row height

    i use this code for auto row height :

    Qt Code:
    1. void QTableWidget::resizeRowsToContents();
    To copy to clipboard, switch view to plain text mode 
    and it word good but when is use this delegate

    Qt Code:
    1. class RichTextDelegate : public QItemDelegate
    2. {
    3. public:
    4. RichTextDelegate()
    5. {
    6. }
    7. void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
    8. {
    9. painter->save();
    10. QVariant value = index.data(Qt::DisplayRole);
    11. if (value.isValid() && !value.isNull()) {
    12. QString text;
    13. text.append("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'tahoma'; font-size:9pt;\">");
    14. text.append(value.toString());
    15. text.append("</p>");
    16.  
    17. doc.setHtml(text);
    18. QAbstractTextDocumentLayout::PaintContext context;
    19. doc.setPageSize( option.rect.size());
    20. painter->setClipRect( option.rect );
    21. painter->translate(option.rect.x(), option.rect.y());
    22. doc.documentLayout()->draw(painter, context);
    23. painter->restore();
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    row height depend on text size dont work ..

    how can i set row height depend on text(height) with that delegate ?
    Last edited by solook; 28th September 2011 at 20:29.

  2. #2
    Join Date
    Nov 2010
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: RichText Delegate and size hint for row height

    i waiting....

Similar Threads

  1. QwtPlot Canvas Size Hint?
    By umituzun84 in forum Qwt
    Replies: 8
    Last Post: 22nd September 2011, 16:21
  2. Replies: 3
    Last Post: 7th July 2011, 12:07
  3. Replies: 2
    Last Post: 27th October 2009, 23:02
  4. QTableView row height via delegate and setRootIndex
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 19:06
  5. QDockArea size hint
    By ksierens in forum Qt Programming
    Replies: 2
    Last Post: 5th April 2006, 15:37

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.