QTreeView 中的超链接
我正在尝试在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您查看过 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.