在 QTreeView 中用鼠标悬停突出显示项目? [英] Highlight item with mouse hover in QTreeView?
本文介绍了在 QTreeView 中用鼠标悬停突出显示项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 QStandardItemModel
,我将它显示为具有多列的 QTreeView
.当鼠标悬停在行上时,如何使其突出显示?
I have a QStandardItemModel
that I am displaying as a QTreeView
with multiple columns. How can I make it highlight rows when the mouse hovers over them?
相关页面
- 如何捕捉鼠标悬停事件pyqt 中的 QTableWidget 项?:使用
QTableWidget
而不是Q*View
的类似问题. - 自定义 QListView:建议很有可能做到使用样式表很容易,但我不太了解 C++.
- 如何突出整个鼠标悬停在 QTableWidget 中的行
- 带有高亮/悬停的 QListView 选择
- How to catch mouse over event of QTableWidget item in pyqt?:
similar question using
QTableWidget
instead ofQ*View
. - Customizing QListView: suggests it is possible to do it very easily with stylesheets, but I don't quite follow the c++.
- How to highlight the entire row on mouse hover in QTableWidget
- QListView selection with highlight/hover
推荐答案
您可以通过样式表来实现
You can achieve this by a stylesheet
treeView->setStyleSheet("QTreeView::item:hover{background-color:#FFFF00;}");
这篇关于在 QTreeView 中用鼠标悬停突出显示项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文