I would like to handle a click to the link in this application of mine:
When I click on the "Output File" link, I would like to be able to generate an action in my application.
As of today, the link is described like this in the rich text QLabel:
<a href="http://google.fr"><span style=" text-decoration: underline; color:#0000ff;">Output File"</span></a>
(generated by Qt Designer)
When clicked, it will open the default web browser to go to Google. That's not what I want; I'd like something like:
<a href="#browse_output"><span style=" text-decoration: underline; color:#0000ff;">Output File"</span></a>
And be able to detect the link that's clicked and react accordingly:
(pseudo code)
if( link_clicked.toString() == "#browse_output" ){
on_browse_output_clicked();
}
Is this possible in Qt with a QLabel (or something approaching) ? How?
Ok, for those interested, I got the answer:
openExternalLinks
" property of the QLabel
QLabel
to your handler.That's all: linkActivated
gives you the URL that the link refers to in argument, so my pseudo code works perfectly.
// header
private slots:
void on_description_linkActivated(const QString &link);
// cpp
void KernelBuild::on_description_linkActivated(const QString &link)
{
if( link == "#browse_output" ){
on_outfilebtn_clicked();
}
}