Multiple hyperlinks in one label text
-
Hi guys,
I have this question. I can simply evaluate hyperlink in label text by using linkActivated like in this example:@label->setText("Some message. <ahref=" ">Agree</a>");
connect(label, SIGNAL(linkActivated(const QString & )), this, SLOT(agree()));
@
But is there some way to react on multiple hyperlinks in one label text differently? Let say I have:
@
label->setText("Some message. <ahref=" ">Agree</a>, or you can always <ahref=" ">Cancel</a>.");
@
And all I want do do is to connect signal from hyperlink Agree to agree() slot and signal from hyperlink Cancel to cancel() slot.
Thanks ;)
-(btw I know I have some errors in sytax, but I had to change it a little for this post to be displayed correcly - meaning ahref and spaces after SIGNAL and SLOT)-Edit: Please use @ tags around code sections, that also solves your layout issue; Andre
-
The linkActivated() signal passes the clicked link, which makes it rather easy to react differently (given that meaningful link names are provided).
@
setText("<a href='agree'>Agree</a>, or you can always <a href='cancel'>Cancel</a>.");void activateLink(const QString &link)
{
if (link == "agree")
{
agree();
}
else if (link == "cancel")
{
cancel();
}
}
@