Multiple hyperlinks in one label text
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.
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")
- else if (link == "cancel")