0

我有一个QString,例如“ https://google.com ”,我应该将其转换QStringQUrl然后将其添加到QUrlQTextEdit当我单击该 URL 时,它将打开https://google.com

下一个问题是,是否可以制作一个 IMAGE-URL?例如:如果“<a href="https://example.com" rel="nofollow noreferrer">https://example.com”打开了一个服装网站,我可以QTextEdit在点击时添加一个 IMAGE-URL 吗?在此图像上,它将打开https://example.com,其中 IMAGE 是打开https://example.com的衣服图像

4

1 回答 1

0

使用QLabelhttps ://doc.qt.io/qt-5/qlabel.html

例子:

label->setText("<a href=\"http://example.com/\">Click Here!</a>");
label->setTextFormat(Qt::RichText);
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
label->setOpenExternalLinks(true);
于 2020-06-05T20:11:39.470 回答