c++ - 不强调 QTextBrowser 中的超链接

标签 c++ qt qt5 qtextbrowser

当设置指向QTextBrowser 的超链接时,我希望该链接带有下划线。在以前的 Qt 版本中(例如 2、3、4),曾经有一个 setLinkUnderline(bool) 方法可能完成了这项工作。如何使用 Qt5 做到这一点?

谢谢

最佳答案

一个可能的解决方案是使用 css 消除下划线:

#include <QApplication>
#include <QTextBrowser>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTextBrowser w;
    w.document()->setDefaultStyleSheet("a{ text-decoration: none; }");
    w.append("<a href=\"https://stackoverflow.com/\">Stack Overflow</a>");
    w.show();
    return a.exec();
}

enter image description here

关于c++ - 不强调 QTextBrowser 中的超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53487933/

相关文章:

c# - 如何从 [C# WP8.1 WRT/SL] 项目中调用 [Unmanaged C++ DLL func]

c++ - QwtPlot setAxisScale,它是如何工作的?

linux - Qt5 Linux 找不到Qt库

c++ - QtQuick2 和 C++ : Using a Repeater

c++ - Eigen log 和 exp 函数类型转换错误

c++ - 在 Qmake 中使用 Qtwidgets

c++ - 在 header 中使用只影响此文件的指令

c++ - 如何获取从 C++ 中的特定类继承的所有已声明类的列表

c++ - QGraphicsScene 中的圆弧

c++ - Qt/C++ QTcpSocket 导致内存泄漏,不知道为什么