当QTableView
编辑控件对当前项目可见,编辑的 shylesheet 发生。当 QTableView
中没有事件的编辑控件时当前项目的样式使用 QTableView { selection-background-color: }
如何只为当前项目设置不同的样式?
最佳答案
Qt 样式表支持子控件和伪状态,您可以使用它来改进您的自定义。 (见 http://qt-project.org/doc/qt-5/stylesheet-reference.html#list-of-pseudo-states)
在这种情况下,您可以使用 ::item
子控件和:focus
伪状态(“当前”伪状态不存在,但 :focus
不存在)。
这是您可以使用的示例:
QTableView::item:focus
{
selection-background-color: yellow;
}
另见 http://qt-project.org/doc/qt-5/stylesheet-examples.html#customizing-qtreeview
关于qt - 如何在 QTableView 中为当前项设置样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23938636/