PyQt4: Clickable links in QLabel?

David Boddie david at boddie.org.uk
Mon Mar 5 20:27:17 EST 2007


On Thursday 01 March 2007 09:00, Tina I wrote:

> A short and sweet question: Is it possible to put a clickable link in a
> QLabel that will open in the systems default browser?

Yes.

> I tried to put in some HTML but it did (of course?) simply display the
> code instead of a link. I also tried to set openExternalLinks 'true' but
> then pyuic4 bombed.

Well, that shouldn't happen. :-(

Can you send a bug report to the PyQt mailing list (assuming you're
subscribed to it) with the error message or backtrace that you get
when this happens?

> I see that QLabel does not have a html text format but I'm still hoping
> it's possible. I really need a link on my main window form.

If you enclose the HTML with <qt> and </qt> tags, the HTML should be
displayed properly. Any other matching tags should also work, so you
could use <p> and </p> if you want.

Setting the label's openExternalLinks property to True should then
enable what you want. You can try this out by previewing the form in
Qt Designer.

David



More information about the Python-list mailing list