Results 1 to 10 of 10

Thread: Rich Text in QTableWidgetItem

  1. #1
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Rich Text in QTableWidgetItem

    I want to be able to use Rich Text in the QTableWidgetItems, but that's not allowed. I'm thinking I am going to have to use a delegate, but I'm not sure on all the steps I'd have to take to just put a QLabel (my guess on what I'd do) into a subclass of QTableWidgetItem. If anyone has some examples or a good explanation of what I need to do, that would be great.

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

    Default Re: Rich Text in QTableWidgetItem

    Please search the forum. The issue has been brought up many times.

  3. #3
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rich Text in QTableWidgetItem

    Where? I've been searching, but I've never seen anyone have a problem with rich text, so it certainly isn't that part of my issue that's been dealt with.

    Now when I look up about QTableWidgetItem (subclass or delegate), there are not examples that work, and often solution has nothing to do with subclassing or making a delegate for the QTableWidgetItem. I admit, I'm new to these forums so they might be buried somewhere or I might not be searching in the correct way.

    Where do I go to figure out this issue?

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

  5. The following user says thank you to wysota for this useful post:

    joshuajcarson (29th August 2008)

  6. #5
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rich Text in QTableWidgetItem

    Thanks for the links.

    http://www.qtcentre.org/forum/f-qt-p...view-8371.html

    This one helped me the most. Had full example code as well as had everything working by the end of the thread.

  7. #6
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rich Text in QTableWidgetItem

    I've used the example from the other thread. I can get the html to display, but I still cannot get it so you can actually interact with the html (as in anchor links). I've even switched out the QTextDocument for a QLabel, but that doesn't seem to be working.

    When the paint event happens, does it create the QTextDocument (or in my case a QLabel), ask it to paint itself, then delete it? Is that why I cannot continue to interacting with my QLabel and have it act as a link?

  8. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rich Text in QTableWidgetItem


  9. #8
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rich Text in QTableWidgetItem

    Yes. I did set it to open external link. I'm thinking I'm just being dumb right now and I'm not sure where. Do I need to have the delegate hold an instance of a QLabel, or is it ok that I create a QLabel during the paint event and that once the paint is over it doesn't exist anymore?

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

    Default Re: Rich Text in QTableWidgetItem

    The delegate doesn't hold anything. You can either use a real label (which will slown down your application significantly if you want to do that for every widget) or handle all the events you want manually from within the delegate's editor events handler.

  11. #10
    Join Date
    Aug 2008
    Location
    Iowa, USA
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rich Text in QTableWidgetItem

    So
    1. Go back to QTextDocument as QLabel is slow
    2. Using the same delegate as before, handle a user click just as I'm now handling the paint events


    Thanks

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. QTableWidgetItem Text Editing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 03:23
  3. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 17:45
  4. Replies: 3
    Last Post: 13th December 2007, 17:10
  5. Rich Text Format
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 4th October 2006, 11: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.