本文整理汇总了Python中AnyQt.QtWidgets.QListView.addActions方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.addActions方法的具体用法?Python QListView.addActions怎么用?Python QListView.addActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QListView
的用法示例。
在下文中一共展示了QListView.addActions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DiscreteVariableEditor
# 需要导入模块: from AnyQt.QtWidgets import QListView [as 别名]
# 或者: from AnyQt.QtWidgets.QListView import addActions [as 别名]
class DiscreteVariableEditor(VariableEditor):
"""An editor widget for editing a discrete variable.
Extends the :class:`VariableEditor` to enable editing of
variables values.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
form = self.layout().itemAt(0)
assert isinstance(form, QFormLayout)
#: A list model of discrete variable's values.
self.values_model = itemmodels.PyListModel(
flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable
)
vlayout = QVBoxLayout(spacing=1, margin=0)
self.values_edit = QListView(
editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed
)
self.values_edit.setItemDelegate(CategoriesEditDelegate(self))
self.values_edit.setModel(self.values_model)
self.values_model.dataChanged.connect(self.on_values_changed)
self.values_edit.selectionModel().selectionChanged.connect(
self.on_value_selection_changed)
self.values_model.layoutChanged.connect(self.on_value_selection_changed)
self.values_model.rowsMoved.connect(self.on_value_selection_changed)
vlayout.addWidget(self.values_edit)
hlayout = QHBoxLayout(spacing=1, margin=0)
self.categories_action_group = group = QActionGroup(
self, objectName="action-group-categories", enabled=False
)
self.move_value_up = QAction(
"\N{UPWARDS ARROW}", group,
toolTip="Move the selected item up.",
shortcut=QKeySequence(Qt.ControlModifier | Qt.AltModifier |
Qt.Key_BracketLeft),
shortcutContext=Qt.WidgetShortcut,
)
self.move_value_up.triggered.connect(self.move_up)
self.move_value_down = QAction(
"\N{DOWNWARDS ARROW}", group,
toolTip="Move the selected item down.",
shortcut=QKeySequence(Qt.ControlModifier | Qt.AltModifier |
Qt.Key_BracketRight),
shortcutContext=Qt.WidgetShortcut,
)
self.move_value_down.triggered.connect(self.move_down)
self.add_new_item = QAction(
"+", group,
objectName="action-add-item",
toolTip="Append a new item.",
shortcut=QKeySequence(QKeySequence.New),
shortcutContext=Qt.WidgetShortcut,
)
self.remove_item = QAction(
"\N{MINUS SIGN}", group,
objectName="action-remove-item",
toolTip="Delete the selected item.",
shortcut=QKeySequence(QKeySequence.Delete),
shortcutContext=Qt.WidgetShortcut,
)
self.add_new_item.triggered.connect(self._add_category)
self.remove_item.triggered.connect(self._remove_category)
button1 = FixedSizeButton(
self, defaultAction=self.move_value_up,
accessibleName="Move up"
)
button2 = FixedSizeButton(
self, defaultAction=self.move_value_down,
accessibleName="Move down"
)
button3 = FixedSizeButton(
self, defaultAction=self.add_new_item,
accessibleName="Add"
)
button4 = FixedSizeButton(
self, defaultAction=self.remove_item,
accessibleName="Remove"
)
self.values_edit.addActions([self.move_value_up, self.move_value_down,
self.add_new_item, self.remove_item])
hlayout.addWidget(button1)
hlayout.addWidget(button2)
hlayout.addSpacing(3)
hlayout.addWidget(button3)
hlayout.addWidget(button4)
hlayout.addStretch(10)
vlayout.addLayout(hlayout)
form.insertRow(1, "Values:", vlayout)
#.........这里部分代码省略.........