如何在 QTableView 中为当前项设置样式表 [英] How to set stylesheet for the current item in QTableView
问题描述
当 QTableView
编辑控件对当前项目可见时,编辑的 shylesheet 发生.当 QTableView
中没有活动编辑控件时,当前项使用 QTableView { selection-background-color: }
如何为当前项设置不同的样式?
Qt 样式表支持子控件和伪状态,您可以使用它来改进您的自定义.(参见
When QTableView
edit control is visible for the current item the shylesheet of the edit takes place. When there is no active edit control in the QTableView
the current item is styled using the QTableView { selection-background-color: }
How to set different style only for the current item?
Qt style sheets support sub-controls and pseudo states, you can use it to improve your customization. (see http://qt-project.org/doc/qt-5/stylesheet-reference.html#list-of-pseudo-states )
In this case you can use the ::item
sub-control and the :focus
pseudo state (the "current" pseudo state doesn't exist, but the :focus
does the same).
This is an example that you can use:
QTableView::item:focus
{
selection-background-color: yellow;
}
See also http://qt-project.org/doc/qt-5/stylesheet-examples.html#customizing-qtreeview
这篇关于如何在 QTableView 中为当前项设置样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!