去除树列表和表格item里面的两种方法,比较推荐第二种:
第一种:去除焦点
ui->treeView->setFocusPolicy(Qt::NoFocus);
但是这种方法有个问题,去除焦点之后,键盘上的上下左右键将失效,不起作用。不推荐。
第二种设置样式:
QTreeView{
background-color: rgb(255, 255, 255);
outline:none;
selection-background-color: rgb(85, 255, 255);
}
QTreeView::item{
background-color: rgb(255, 255, 255);
}
QTreeView::item:selected{
background-color: rgb(85, 255, 255);
}
推荐第二种