QListView项目背景颜色
我正在尝试更改当前鼠标悬停的项目的背景颜色。
到目前为止我所做的是:我对 QListView 进行子类化并在 ctor 中:
connect(this,SIGNAL(entered(QModelIndex)),this,SLOT(enteredSlot(QModelIndex)));
这项工作基本上需要在插槽 enteredSlot(QModelIndex)
中完成,但我不知道如何完成。
I'm trying to change the background color of the item which currently has the mouse hover.
What I've done so far is: I subclassed QListView and in the ctor:
connect(this,SIGNAL(entered(QModelIndex)),this,SLOT(enteredSlot(QModelIndex)));
The job basically needs to be done in the slot enteredSlot(QModelIndex)
but I have no idea how.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 设置QListView 的样式表。如果您以前没有使用过样式表,您可能想稍微回顾一下文档,但与自定义小部件外观相关的大多数常见活动都可以使用它们来完成。不要将它们与 QStyles 混淆,QStyles 是一种不同的样式机制。
You can achieve what you are trying to do a bit easier by setting a style sheet for your QListView. If you haven't worked with style sheets before you may want to back track in the documentation a bit but most common activities related to customizing the appearance of widgets can be done using them. Do not confuse them with QStyles which is a different styling mechanism.