MDGSF Software Engineer

[Qt] 打开网页

2016-03-06
Qt
 

1.用QLabel

label->setText(tr("<style>a{text-decoration: none}</style><a style='color: #09A3DC;' href=\"http://www.baidu.com\">baidu</a>"));
label->setTextFormat(Qt::RichText);
label->setOpenExternalLinks(true);

2.用 openUrl

要记得加 "http://"
最开始没有加,怎么也打不开,呵呵。
const QUrl url(tr("http://www.baidu.com"));
QDesktopServices::openUrl(url);

weixingongzhonghao

Comments

Content