使QLabel表现得像超链接 [英] Making QLabel behave like a hyperlink

查看:63
本文介绍了使QLabel表现得像超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使QLabel表现得像链接?我的意思是说我希望能够单击它,然后在它上面调用一些命令。

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.

推荐答案

QLabel 已经做到了

示例代码:

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

这篇关于使QLabel表现得像超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆