PyQt4: Clickable links in QLabel?

T

Tina I

Hi everyone,

A short and sweet question: Is it possible to put a clickable link in a
QLabel that will open in the systems default browser?
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.
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.

Thanks
Tina
 
D

David Boddie

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
 
T

Tina I

David said:
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?


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
Thanks David,

This is embarrassing... but my PyQt4 was too old *blush*
I can't believe I didn't think of double checking what version I had
installed. A swift upgrade and it works like a charm :)

Tina
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top