PDA

View Full Version : Rich Text in QTableWidgetItem



joshuajcarson
28th August 2008, 19:30
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.

wysota
28th August 2008, 19:48
Please search the forum. The issue has been brought up many times.

joshuajcarson
28th August 2008, 21:09
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?

wysota
29th August 2008, 08:37
http://www.qtcentre.org/forum/f-qt-programming-2/t-displaying-richtext-on-itemwidgets-15591.html
http://www.qtcentre.org/forum/f-newbie-4/t-qlistwidget-or-qlistview-with-qlabels-15301.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-different-text-block-colours-in-qlistview-qlistwidget-14528.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-word-wrap-in-qlistview-8371.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-rich-text-in-tree-widget-9845.html

If that's not enough, open the search box and type in "rich text".

joshuajcarson
29th August 2008, 13:58
Thanks for the links.

http://www.qtcentre.org/forum/f-qt-programming-2/t-word-wrap-in-qlistview-8371.html

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

joshuajcarson
29th August 2008, 19:06
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?

aamer4yu
30th August 2008, 10:13
Did u use QLabel::setOpenExternalLinks() ??? :)

joshuajcarson
30th August 2008, 15:58
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?

wysota
31st August 2008, 16:59
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.

joshuajcarson
2nd September 2008, 15:49
So

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


Thanks