Python PyQt5.QtCore 模块,QSortFilterProxyModel() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用PyQt5.QtCore.QSortFilterProxyModel()

项目:Visualization    作者:nwrush    | 项目源码 | 文件源码
def __init__(self, parent, data=None):
        super(ListFrame, self).__init__(parent, data_manager=data)

        self.ui = topics_list.Ui_topicsList()
        self.ui.setupUi(self)

        self._filter = QtCore.QSortFilterProxyModel()
        self._model = ListModel(self.data.idea_names.values(), self)

        self._onselect_listener = listener.Listener()

        self._filter.setSourceModel(self._model)
        self.ui.listWidget.setModel(self._filter)

        self.ui.listWidget.selectionModel().selectionChanged.connect(self._on_select_model)
        self.ui.filterText.textEdited.connect(self._filter.setFilterFixedString)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def setModel(self, model):
        smodel = QtCore.QSortFilterProxyModel(parent=self)
        smodel.setSourceModel(model)
        ret = super(VqtView, self).setModel(smodel)
        c = len(model.columns)
        for i in range(c):
            self.resizeColumnToContents(i)
        return ret
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AdvComboBox, self).__init__(parent)

        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setEditable(True)

        # add a filter model to filter matching items
        self.pFilterModel = QSortFilterProxyModel(self)
        self.pFilterModel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.pFilterModel.setSourceModel(self.model())

        # add a completer, which uses the filter model
        self.completer = QCompleter(self.pFilterModel, self)
        # always show all (filtered) completions
        self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)

        self.setCompleter(self.completer)

        # connect signals

        def filter_function(text):
            self.pFilterModel.setFilterFixedString(str(text))

        self.lineEdit().textEdited.connect(filter_function)
        self.completer.activated.connect(self.on_completer_activated)

    # on selection of an item from the completer, select the corresponding item from combobox