Results 1 to 6 of 6

Thread: Rich text in QListView

  1. #1
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Rich text in QListView

    Hello, I've got a model with two columns of strings and I want to have them displayed in QListView as one rich formatted text - what is the simpliest solution? Do I have to extend QStyledItemDelegate in order to do that? Or insert QLabel into QListView?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Rich text in QListView

    the easiest and best way would be a delegate as you mentioned. With it data function you can access both columns and paint them. If you want rich text support use a QTextDocument to render it (only when really needed).

  3. #3
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Rich text in QListView

    OK, let's say that I did it - got my own delegate and it displays text as I wanted, BUT - do I have to rewrite whole painting? Is there any possibility to use it from QItemDelegate instead? (I mean selection rects etc., now my text disappears when has mouse over it.)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Rich text in QListView

    Quote Originally Posted by Fenix Voltres View Post
    (I mean selection rects etc., now my text disappears when has mouse over it.)
    Then first call the base class function and then do your painting. But better do all "yourself": See QStylePainter to get the job easier done.

  5. #5
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Rich text in QListView

    Quote Originally Posted by Lykurg View Post
    Then first call the base class function and then do your painting.
    Then I would have text rendered two times - as plain and rich at the same time. Thanks for the info, I'll check the QStylePainter class out.

  6. #6
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Rich text in QListView


Similar Threads

  1. How to use rich text in a QComboBox?
    By aarunt1 in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2010, 20:20
  2. Rich text in QGraphicsTextItem
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2008, 20:08
  3. Rich text with QPainter?
    By sarefo in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2008, 14:40
  4. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  5. Rich Text Format
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 4th October 2006, 10:53

Tags for this Thread

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.