问题
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?
回答1:
Have you checked out QAbstractItemView::setIndexWidget? You could create a QLabel like you said and pass it this function for the correct index.
来源:https://stackoverflow.com/questions/7087064/hyperlinks-in-qtreeview