Hyper-Link a QLabel?
I have 2 QLabel's in my Dialog.
I want to hyper link both of them but with different behaviour.
For the 1st one I want it to hyper link to a local folder.
So that when the text in the QLabel is clicked it should open the folder in a new window.
For the 2nd QLabel I want it to hyper link to a website.
So that when the text in the QLabel is clicked it should open the default browser & open the link that I have specified in code.
How do I do this?
Create a slot which will be connected to the QLabel::linkActivated(QString) signal... And there choose your destiny... If you don't want hassle to check the URL just make 2 slots, one for each QLabel and for each slot open the URL in a certain way... With QDesktopServices::openUrl(QUrl) for websites and for the other load the file where you wanted it to be loaded... And voila
Thank You b1gsnak3.
On first look it seems my job is done.
But I will get back to you tomorrow in case there is a problem.
Sorry but I am unable to implement the functionality.
Can you please show some code?
& what is anchored link that is mentioned in the documentation & how do I set it?
See the Qt docs for SetOpenExternalLinks under QLabel class, for some sample you can use the following link "this":http://www.qtcentre.org/threads/4968-QLabel-links
QDeskTopServices::OpenURL also takes paths to local folders, therefore it can open local folders as well. The URL should however be file:/// . Ref docs of QURL class.