本文整理汇总了Python中AnyQt.QtWidgets.QLineEdit.isModified方法的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit.isModified方法的具体用法?Python QLineEdit.isModified怎么用?Python QLineEdit.isModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.isModified方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VariableEditor
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import isModified [as 别名]
class VariableEditor(QWidget):
"""
An editor widget for a variable.
Can edit the variable name, and its attributes dictionary.
"""
variable_changed = Signal()
def __init__(self, parent=None, **kwargs):
super().__init__(parent, **kwargs)
self.var = None # type: Optional[Variable]
layout = QVBoxLayout()
self.setLayout(layout)
self.form = form = QFormLayout(
fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow,
objectName="editor-form-layout"
)
layout.addLayout(self.form)
self.name_edit = QLineEdit(objectName="name-editor")
self.name_edit.editingFinished.connect(
lambda: self.name_edit.isModified() and self.on_name_changed()
)
form.addRow("Name:", self.name_edit)
vlayout = QVBoxLayout(margin=0, spacing=1)
self.labels_edit = view = QTreeView(
objectName="annotation-pairs-edit",
rootIsDecorated=False,
editTriggers=QTreeView.DoubleClicked | QTreeView.EditKeyPressed,
)
self.labels_model = model = DictItemsModel()
view.setModel(model)
view.selectionModel().selectionChanged.connect(
self.on_label_selection_changed)
agrp = QActionGroup(view, objectName="annotate-action-group")
action_add = QAction(
"+", self, objectName="action-add-label",
toolTip="Add a new label.",
shortcut=QKeySequence(QKeySequence.New),
shortcutContext=Qt.WidgetShortcut
)
action_delete = QAction(
"\N{MINUS SIGN}", self, objectName="action-delete-label",
toolTip="Remove selected label.",
shortcut=QKeySequence(QKeySequence.Delete),
shortcutContext=Qt.WidgetShortcut
)
agrp.addAction(action_add)
agrp.addAction(action_delete)
view.addActions([action_add, action_delete])
def add_label():
row = [QStandardItem(), QStandardItem()]
model.appendRow(row)
idx = model.index(model.rowCount() - 1, 0)
view.setCurrentIndex(idx)
view.edit(idx)
def remove_label():
rows = view.selectionModel().selectedRows(0)
if rows:
assert len(rows) == 1
idx = rows[0].row()
model.removeRow(idx)
action_add.triggered.connect(add_label)
action_delete.triggered.connect(remove_label)
agrp.setEnabled(False)
self.add_label_action = action_add
self.remove_label_action = action_delete
# Necessary signals to know when the labels change
model.dataChanged.connect(self.on_labels_changed)
model.rowsInserted.connect(self.on_labels_changed)
model.rowsRemoved.connect(self.on_labels_changed)
vlayout.addWidget(self.labels_edit)
hlayout = QHBoxLayout()
hlayout.setContentsMargins(0, 0, 0, 0)
button = FixedSizeButton(
self, defaultAction=self.add_label_action,
accessibleName="Add",
)
hlayout.addWidget(button)
button = FixedSizeButton(
self, defaultAction=self.remove_label_action,
accessibleName="Remove",
)
hlayout.addWidget(button)
hlayout.addStretch(10)
vlayout.addLayout(hlayout)
form.addRow("Labels:", vlayout)
#.........这里部分代码省略.........