Hyperlink text in QLabel to open web browser
Hi all,
I'm developing an about window. In this window I have some urls.
For example, if my label has the text: "http://www.qtcentre.org" I want that when the user click in the label, the web browser opens with the specified url.
What is the best way to perform this?
Regards.
Re: Hyperlink text in QLabel to open web browser
Re: Hyperlink text in QLabel to open web browser
Hi Zlatomir,
I have set openExternalLinks, LinksAccessibleByMouse and LinksAccessibleByKeyboard to true, but nothing happen when I click over the QLabel.
What's wrong?
Regards.
Re: Hyperlink text in QLabel to open web browser
Is it a link? I mean the text should be like this:
Code:
label.openExternalLinks(true);
label.setText("<a href=\"http://www.qtcentre.org\" />QtCentre</a>");
Re: Hyperlink text in QLabel to open web browser
Hi srazi,
I have used your code but nothing happens when I click over the label. Have you tested the code?
Regards.
Re: Hyperlink text in QLabel to open web browser
Did You set text format to Plain text on QLabel? If so change it to Auto / Rich text.
Re: Hyperlink text in QLabel to open web browser
hello world
the right code is :
QLabel label;
label.openExternalLinks(true);
label.setText("<a href=\"http://www.qtcentre.org\">QtCentre</a>");
i tested and it's work
Re: Hyperlink text in QLabel to open web browser
The really right code is:
QLabel label;
label.setOpenExternalLinks(true);
label.setText("<a href="http://www.qtcentre.org">QtCentre</a>");