PDA

View Full Version : 2 questions on QPainter and html



jiveaxe
4th September 2007, 09:49
Hi,
here are my questions:

1) I have used QTextDocument for painting a html link; it is rendered but obviously i can't click on it for opening web browser. How can I accomplish this?

2) Is QTextDocument the only class which permits rendering html code with qpainter? I ask for this because either, in my application, use always QTextDocument for rendering text or I have to do a lot of editing for rendering with the same look simple text in painter->drawText() and html text in QTextDocument.

Thanks

jpn
4th September 2007, 09:55
You can use QLabel for showing non-editable HTML, including links. QLabel can also automatically open external links for you, see property called openExternalLinks (http://doc.trolltech.com/latest/qlabel.html#openExternalLinks-prop) for more details.

jiveaxe
4th September 2007, 10:07
Hi jpn,
i know this property of QLabel but I have created a drawingArea and there, using a lot of painters in paintEvent, I am designing the interface; so I'm not sure of the final look if i put above this a QLabel.

Regards

jpn
4th September 2007, 11:30
Well, QTextDocument only describes a text document structure. Rendering it on arbitrary paint device doesn't give you text interaction of any kind. To be able to open links, you will have to catch mouse events by hand and use QDesktopServices to open URLs in external applications.