I am using Pyside2 for python GUI. I am currently working on a QTableWidget. This QTableWidget has 3 columns and 10 rows.
First, when I click on any item in the QTableWidget, I want the entire row to be selected. So I set the selection behaviour using
self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
Next, I want the entire row to be highlighted in a rounded rectangle shape, so I set the qt style sheet:
QTableWidget::item:selected{
outline: none开发者_开发百科;
background-color: #dbe7f4;
border-radius: 9px;
}
But the result is like this:
This is not what I expected. As shown in the picture, every cell in this row is highlighted with a rounded rectangle. But I expect the entire row to be highlighted with a rounded rectangle, which means I want the item in the first row to be 'rounded' in the top-left corner and bottom-left corner, and the item in the third row to be 'rounded' in the top-right corner and bottom-right corner.
Later I tried the qss below:
QTableWidget::item:column(0) {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
background-color: #dbe7f4;
}
QTableWidget::item:column(2) {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
background-color: #dbe7f4;
}
However, it is not working. I also tried:
QTableWidget::item:selected:column(0) {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
background-color: #dbe7f4;
}
QTableWidget::item:selected:column(2) {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
background-color: #dbe7f4;
}
It is not working either. It just didn't make any difference.
What am I supposed to do? Is there a better way?
精彩评论