How to set stylesheet for the current item in QTableView

后端 未结 3 987
攒了一身酷
攒了一身酷 2020-12-03 16:08

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 QTableVie

3条回答
  •  -上瘾入骨i
    2020-12-03 16:55

    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;
    }
    

    enter image description here

    See also http://qt-project.org/doc/qt-5/stylesheet-examples.html#customizing-qtreeview

提交回复
热议问题