兩種方式都可以,一個通用,一個具體 //具體 QListWidget#listWidget_param::Item:hover, QListWidget#listWidget_param::Item:selected { background-color:rgba(22, 29, 36, 1); } QListWidget#listWidget_param::Item:selected:!active { background-color:rgba(22, 29, 36, 1); } //通用 QListWidget::Item:hover, QListWidget::Item:selected { background-color:rgba(22, 29, 36, 1); } QListWidget::Item:selected:!active { background-color:rgba(22, 29, 36, 1); } QListWidget{ //去掉選中時的虛線框 outline:0px; }
QListWidget頂上默認顯示邊框,隱藏邊框:
m_listWidget->setFrameShape(QListWidget::NoFrame);