本文整理汇总了Python中PySide.QtGui.QCompleter.setCompletionColumn方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.setCompletionColumn方法的具体用法?Python QCompleter.setCompletionColumn怎么用?Python QCompleter.setCompletionColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QCompleter
的用法示例。
在下文中一共展示了QCompleter.setCompletionColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: config_completer
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCompletionColumn [as 别名]
def config_completer(line_edit, model, field):
# sets up a completer based on a QSqlTableModel for the specified field on a QLineEdit
completer = QCompleter()
completer.setModel(model)
completer.setCompletionColumn(model.fieldIndex(field))
completer.setCompletionMode(QCompleter.PopupCompletion)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.activated.connect(line_edit.returnPressed)
line_edit.setCompleter(completer)
示例2: __init__
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCompletionColumn [as 别名]
def __init__(self, model, index, parent=None):
super(ObservationDialog, self).__init__(parent)
self.logger = Logger('root.observationDialog')
self.logger.debug('Debug set to: %s' % str(parent.logger.debugging))
self.setupUi(self)
# self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
# An observation model is passed to the constructor as a parameter
self.model = model
# Build a QCompleter that is based on a species model's species name.
# This way user can start typing the name in a line edit and the
# completion will suggest suitable species names based on the model
# TODO: language for the species name completion needs to be handled
# TODO: both completers have model column indexes hard coded in, thus
# they will break if the model is modified
sppCompleter = QCompleter(self)
sppCompleter.setModel(self.model.data_model)
sppCompleter.setCompletionColumn(4)
sppCompleter.setCompletionMode(QCompleter.InlineCompletion)
sppCompleter.setCaseSensitivity(Qt.CaseInsensitive)
self.sppLineEdit.setCompleter(sppCompleter)
# Build a QCompleter that is based on a species model's abbreviation.
# This way user can start typing the abbreviation in a line edit and the
# completion will suggest suitable species names based on the model
abbrCompleter = QCompleter(self)
abbrCompleter.setModel(self.model.data_model)
abbrCompleter.setCompletionColumn(1)
abbrCompleter.setCompletionMode(QCompleter.InlineCompletion)
self.abbrLineEdit.setCompleter(abbrCompleter)
# The underlying (observation) model is automatically updated through
# a QDataWidgetMapper
self.mapper = QDataWidgetMapper(self)
self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)
self.mapper.setModel(model)
# ID is mapped to a disabled dummy label in order to include it in the
# WidgetMapper --> not very elegant
self.mapper.addMapping(self.idLineEdit, model.ID)
self.mapper.addMapping(self.sppLineEdit, model.SPECIES)
self.mapper.addMapping(self.abbrLineEdit, model.ABBR)
self.mapper.addMapping(self.countSpinBox, model.COUNT)
self.mapper.addMapping(self.dateTimeEdit, model.TIME)
self.mapper.addMapping(self.locLineEdit, model.LOCATION)
self.mapper.addMapping(self.notesTextEdit, model.NOTES)
self.mapper.setCurrentModelIndex(index)
self.firstButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.FIRST))
self.prevButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.PREV))
self.nextButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.NEXT))
self.lastButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.LAST))
self.saveButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.CURRENT))
self.closeButton.clicked.connect(self.reject)
self.sppLineEdit.editingFinished.connect(self.update_fields)