问题描述
我正在尝试在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 alink 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.
任何想法?
推荐答案
你有没看过?你可以像你说的那样创建一个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中的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!