Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

how can I make a QLabel to behave like a link? What I mean is that I'd like to be able to click on it and then this would invoke some command on it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
277 views
Welcome To Ask or Share your Answers For Others

1 Answer

QLabel does this already.

Sample code:

myLabel->setText("<a href="http://example.com/">Click Here!</a>");
myLabel->setTextFormat(Qt::RichText);
myLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
myLabel->setOpenExternalLinks(true);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...