В данном случае можно увидеть рамку в элементе номер 3 (ее нужно убрать)
вот код
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QBrush, QColor
import sys
class SelectDelegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
super().initStyleOption(option, index)
if self.parent().currentIndex() == index.row():
option.backgroundBrush = QColor(Qt.red)
class Ui_MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.comboBox = QComboBox(self)
self.comboBox.setItemDelegate(SelectDelegate(self.comboBox))
self.comboBox.addItem("1")
self.comboBox.addItem("2")
self.comboBox.addItem("3")
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = Ui_MainWindow()
MainWindow.show()
sys.exit(app.exec_())
я знаю про такое решение
self.comboBox.setStyleSheet('''
QComboBox QListView{
outline: 0px;
}''')
но в данном случае оно не работает