在 QTreeView 中用鼠标悬停突出显示项目? [英] Highlight item with mouse hover in QTreeView?

查看:44
本文介绍了在 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?

相关页面

  • How to catch mouse over event of QTableWidget item in pyqt?: similar question using QTableWidget instead of Q*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屋!

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