PDA

View Full Version : Using most of QItemDelegate



joshuajcarson
25th September 2008, 22:53
QItemDelegate does almost all that I want it to. It's paint just doesn't display html correctly. But the rest of the paint method is amazing and is something I want to use. How do I go about using all of it's paint method besides the part where is prints text?

I've already tried giving it QModelIndex() instead of the real index, then just doing my custom painting of a QTextDocument, but then it doesn't display background colors correctly. Is there some way for me to use all of QItemDelegate::paint besides the part where it prints out text?

Bonus Points! Is there something that exists already to print out html that also handles special cases (selected, out of focus, exc) so I don't also have to handle all of that myself?

wysota
26th September 2008, 10:22
As for painting, there is at least one implementation of the delegate that does that available on the forum. As for handling events, you have to do it yourself or bug Trolltech to make QTextControl class public :)

joshuajcarson
26th September 2008, 17:44
I've checked the forums (QItemDelegate html), but I was unable to find anything besides the library that you built. I'd have to buy that, which wouldn't fly over so well with the bosses.

Do I just have to figure out all the special cases and handle them by myself? Is there some chart that exists that I can use as a cheat sheet for all the different states I might need to care about?

wysota
26th September 2008, 22:34
I've checked the forums (QItemDelegate html), but I was unable to find anything besides the library that you built. I'd have to buy that, which wouldn't fly over so well with the bosses.
Naaa.... there is a rich text delegate here somewhere. Try looking for "rich text delegate". Or rip out QTextControl as I suggested earlier. You'll need to rewrite its P-IMPL, but it should take no more than few hours of work.

joshuajcarson
6th October 2008, 17:02
There is a very easy way to use more of QItemDelegate I've found.

Most of the functionality that I wanted was already broken up and just waiting for me to use it. They are the protected methods like drawBackground and drawFocus. I just called them and handled drawing everything else. It works exactly as I'd expect it to. I really should be checking out Qt Assistant more often and seeing all that Qt has already given me to work with.