Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有自定义模型和委托的 QTableView。任务是创建包含图像和超链接的单元格。通过单击图像用户将超链接复制到剪贴板,并通过单击超链接用户应该在浏览器中打开链接。
这是一个可能的任务吗?
当然有可能。
解决此问题的一种方法是使用setIndexWidget()视图调用,您可以使用 html (rtf) 绕过QLabel图像或超链接或两者兼而有之。
setIndexWidget()
QLabel
另一种方法是拥有自己的子类QItemDelegate,您可以在其中重新实现createEditor()和设置持久性编辑器openPersistenEditor()。
QItemDelegate
createEditor()
openPersistenEditor()