tags:

views:

37

answers:

1

I'm coding a small and basic error tracker with Qt. The whole application is in a QTable. Each error is linked to a file ; so, one of the columns of my table deals with that. I have a QLabel and a button next to it ; you click on the button to select a file, and then, the label displays the name of the file.

What I'd like to do now : the QLabel appears as a link, and when you click on it, it opens the file (with whatever app is associated to the file's extension). I'd rather it in the form of a link, because it's more obvious for the user. If I don't manage to do it, I'll go with a home QLabel herited class with a click signal, but it's not quite the same thing.

So, is what I want to do possible ? And how would you do it ? Thanks in advance for your help !

+3  A: 

You can use html in QLabel's text, so lets use that. Then set the QLabel to automatically open the link:

ui->label->setText("<a href=\"file:///C:/yourfile.doc\">Link to file</a>");
ui->label->setOpenExternalLinks(true);
Roku
Thanks so much ! Should have thought about it. Thanks again.
Raveline