是否可以将样式表应用于与QCombobox绑定的QCompleter的弹出窗口部分?如果没有,它是否需要委托魔法?如果是这样的话,那怎么可能会像他们一样工作,往往会让我感到困惑.这是我的小部件代码:
class autoFillField(QComboBox):
def __init__(self, parent=None):
super(autoFillField, self).__init__(parent)
self.setFocusPolicy(Qt.NoFocus)
self.setEditable(True)
self.addItem("")
self.pFilterModel = QSortFilterProxyModel(self)
self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
self.pFilterModel.setSourceModel(self.model())
self.completer = QCompleter(self.pFilterModel, self)
self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
self.setCompleter(self.completer)
self.setStyleSheet(STYLING FOR COMBOBOX HERE, BUT NOT POPUP)
self.lineEdit().textEdited[unicode].connect(self.pFilterModel.setFilterFixedString)
def on_completer_activated(self, text):
if text:
index = self.findText(text)
self.setCurrentIndex(index)
def setModel(self, model):
super(autoFillField, self).setModel(model)
self.pFilterModel.setSourceModel(model)
self.completer.setModel(self.pFilterModel)
def setModelColumn(self, column):
self.completer.setCompletionColumn(column)
self.pFilterModel.setFilterKeyColumn(column)
super(autoFillField, self).setModelColumn(column)
弹出式样式是否会发生在组合框类中,还是会发生在通过addItems输入数据的外部?提前致谢.