PDA

View Full Version : Links inside view



naresh
20th September 2006, 17:19
Hi there, i'm trying to display links inside TreeView with my custom model.

1. Item has element QTextDocument *doc;
2. doc contains HTML content ( i.e <a href="http://link">http://link</a>).
3. delegate accesses items doc and uses doc->drawContents( painter, option.rect )

I think it should paint document contents inside of view but it doesn't... in the place where it should be painted there is empty hole (i'm using QTextDocument::size and QTextDocument::setTextWidth to caclulate size hint). I know how to handle clicks on link with eventFilter etc. but i have no idea why it doesn't want to paint inside view. any ideas?

naresh
21st September 2006, 15:49
Here is some code:

delegate:

rosterItem *item = static_cast<rosterItem*> (index.internalPointer());
item->descr->setHtml( "<a href=\"http://link\">http://link</a>" );
item->descr->drawContents( painter, QRectF( 0,(qreal)( index.row()*20 ),100,20 ) );

That's all what delegate does, it should draw link for each item but it doesn't. in list i have something like 8 items. (items with different background are "groups" in this tree view) but link is painted only ONCE. maybe it's some kind of Qt bug?