QTreeView中的超链接 [英] Hyperlinks in QTreeView

查看:240
本文介绍了QTreeView中的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在QTreeView中显示可点击的链接。我已经创建了自己的QStyledItemDelegate,我可以绘制看起来像链接的文本,但不像
链接那样可点击。

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.

我想到的一个选项是创建一个带链接的QLabel,并在QTreeView单元格中绘制QLabel。唯一的问题是我无法弄清楚如何将QLabel添加到QTreeView。

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.

任何想法?

推荐答案

你有没看过 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.

这篇关于QTreeView中的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆