优化QTableView\QTreeView\QListView丢失焦点时item的显示样式
This commit is contained in:
parent
a2fc55ced7
commit
b216828f1f
|
|
@ -150,6 +150,11 @@ void AttributeTableDelegate::paint(QPainter* painter, const QStyleOptionViewItem
|
||||||
opt.palette.setColor(QPalette::Text, Qt::red);
|
opt.palette.setColor(QPalette::Text, Qt::red);
|
||||||
opt.palette.setColor(QPalette::HighlightedText, Qt::red);
|
opt.palette.setColor(QPalette::HighlightedText, Qt::red);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//确保失去焦点时高亮颜色,因为上面对于更改的内容会有特殊处理,所以不能放在qss样式中统一处理,qss样式会优先这里被执行
|
||||||
|
opt.palette.setColor(QPalette::HighlightedText, QColor(240, 240, 240));
|
||||||
|
}
|
||||||
|
|
||||||
//处理被选择时的背景色,注意:如果qss中有设置,会覆盖此处逻辑
|
//处理被选择时的背景色,注意:如果qss中有设置,会覆盖此处逻辑
|
||||||
if(option.state.testFlag(QStyle::State_Selected))
|
if(option.state.testFlag(QStyle::State_Selected))
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@ QTableView::item:hover
|
||||||
QTableView::item:selected
|
QTableView::item:selected
|
||||||
{
|
{
|
||||||
background-color: rgb(49, 91, 125);
|
background-color: rgb(49, 91, 125);
|
||||||
|
}
|
||||||
|
QTableView::item:selected:!active
|
||||||
|
{
|
||||||
|
color: rgb(240, 240, 240);
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,10 @@ QTreeView::item:selected
|
||||||
{
|
{
|
||||||
background-color: rgb(49, 91, 125);
|
background-color: rgb(49, 91, 125);
|
||||||
}
|
}
|
||||||
|
QTreeView::item:selected:!active
|
||||||
|
{
|
||||||
|
color: rgb(240, 240, 240);
|
||||||
|
}
|
||||||
QTreeView::branch:has-children:!has-siblings:closed,
|
QTreeView::branch:has-children:!has-siblings:closed,
|
||||||
QTreeView::branch:closed:has-children:has-siblings
|
QTreeView::branch:closed:has-children:has-siblings
|
||||||
{
|
{
|
||||||
|
|
@ -262,6 +266,10 @@ QListView::item:selected
|
||||||
{
|
{
|
||||||
background-color: rgb(49, 91, 125);
|
background-color: rgb(49, 91, 125);
|
||||||
}
|
}
|
||||||
|
QListView::item:selected:!active
|
||||||
|
{
|
||||||
|
color: rgb(240, 240, 240);
|
||||||
|
}
|
||||||
</string>
|
</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue