QTreeView 中的超链接

发布于 2024-11-29 16:38:45 字数 207 浏览 7 评论 0原文

我正在尝试在 QTreeView 中显示可点击的链接。我创建了自己的 QStyledItemDelegate,并且可以绘制看起来像链接的文本,但不能像 链接将是。

我正在考虑的一个选择是创建一个带有链接的 QLabel,并在 QTreeView 单元格内绘制 QLabel。唯一的问题是我不知道如何将 QLabels 添加到 QTreeView 中。

有什么想法吗?

I'm trying to display clickable links within a QTreeView. I've created my own QStyledItemDelegate, and I can draw text that looks like a link, but isn't clickable like a
link would be.

One option I'm thinking of is creating a QLabel with a link, and drawing the QLabel inside the QTreeView cells. The only problem is that I can't figure out how to add QLabels to the QTreeView.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2024-12-06 16:38:46

您查看过 QAbstractItemView::setIndexWidget 吗?您可以像您所说的那样创建一个 QLabel 并将此函数传递给它以获得正确的索引。

Have you checked out QAbstractItemView::setIndexWidget? You could create a QLabel like you said and pass it this function for the correct index.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文