QUndoGroup¶
The
QUndoGroup
class is a group ofQUndoStack
objects. More…
Synopsis¶
Functions¶
def
activeStack
()def
addStack
(stack)def
canRedo
()def
canUndo
()def
createRedoAction
(parent[, prefix=””])def
createUndoAction
(parent[, prefix=””])def
isClean
()def
redoText
()def
removeStack
(stack)def
stacks
()def
undoText
()
Slots¶
def
redo
()def
setActiveStack
(stack)def
undo
()
Signals¶
def
activeStackChanged
(stack)def
canRedoChanged
(canRedo)def
canUndoChanged
(canUndo)def
cleanChanged
(clean)def
indexChanged
(idx)def
redoTextChanged
(redoText)def
undoTextChanged
(undoText)
Detailed Description¶
For an overview of the Qt’s undo framework, see the overview.
An application often has multiple undo stacks, one for each opened document. At the same time, an application usually has one undo action and one redo action, which triggers undo or redo in the active document.
QUndoGroup
is a group ofQUndoStack
objects, one of which may be active. It has anundo()
andredo()
slot, which callsundo()
andredo()
for the active stack. It also has the functionscreateUndoAction()
andcreateRedoAction()
. The actions returned by these functions behave in the same way as those returned bycreateUndoAction()
andcreateRedoAction()
of the active stack.Stacks are added to a group with
addStack()
and removed withremoveStack()
. A stack is implicitly added to a group when it is created with the group as its parentQObject
.It is the programmer’s responsibility to specify which stack is active by calling
setActive()
, usually when the associated document window receives focus. The active stack may also be set withsetActiveStack()
, and is returned byactiveStack()
.When a stack is added to a group using
addStack()
, the group does not take ownership of the stack. This means the stack has to be deleted separately from the group. When a stack is deleted, it is automatically removed from a group. A stack may belong to only one group. Adding it to another group will cause it to be removed from the previous group.A
QUndoGroup
is also useful in conjunction withQUndoView
. If aQUndoView
is set to watch a group usingsetGroup()
, it will update itself to display the active stack.
- class PySide2.QtWidgets.QUndoGroup([parent=None])¶
- param parent:
Creates an empty
QUndoGroup
object with parentparent
.See also
- PySide2.QtWidgets.QUndoGroup.activeStack()¶
- Return type:
Returns the active stack of this group.
If none of the stacks are active, or if the group is empty, this function returns
None
.See also
- PySide2.QtWidgets.QUndoGroup.activeStackChanged(stack)¶
- Parameters:
stack –
PySide2.QtWidgets.QUndoStack
- PySide2.QtWidgets.QUndoGroup.addStack(stack)¶
- Parameters:
stack –
PySide2.QtWidgets.QUndoStack
Adds
stack
to this group. The group does not take ownership of the stack. Another way of adding a stack to a group is by specifying the group as the stack’s parentQObject
inQUndoStack()
. In this case, the stack is deleted when the group is deleted, in the usual manner of QObjects.See also
removeStack()
stacks()
QUndoStack()
- PySide2.QtWidgets.QUndoGroup.canRedo()¶
- Return type:
bool
Returns the value of the active stack’s
canRedo()
.If none of the stacks are active, or if the group is empty, this function returns
false
.See also
- PySide2.QtWidgets.QUndoGroup.canRedoChanged(canRedo)¶
- Parameters:
canRedo – bool
- PySide2.QtWidgets.QUndoGroup.canUndo()¶
- Return type:
bool
Returns the value of the active stack’s
canUndo()
.If none of the stacks are active, or if the group is empty, this function returns
false
.See also
- PySide2.QtWidgets.QUndoGroup.canUndoChanged(canUndo)¶
- Parameters:
canUndo – bool
- PySide2.QtWidgets.QUndoGroup.cleanChanged(clean)¶
- Parameters:
clean – bool
- PySide2.QtWidgets.QUndoGroup.createRedoAction(parent[, prefix=""])¶
- Parameters:
parent –
PySide2.QtCore.QObject
prefix – str
- Return type:
Creates an redo
QAction
object with parentparent
.Triggering this action will cause a call to
redo()
on the active stack. The text of this action will always be the text of the command which will be redone in the next call toredo()
, prefixed byprefix
. If there is no command available for redo, if the group is empty or if none of the stacks are active, this action will be disabled.If
prefix
is empty, the default template “Redo %1” is used instead of prefix. Before Qt 4.8, the prefix “Redo” was used by default.See also
- PySide2.QtWidgets.QUndoGroup.createUndoAction(parent[, prefix=""])¶
- Parameters:
parent –
PySide2.QtCore.QObject
prefix – str
- Return type:
Creates an undo
QAction
object with parentparent
.Triggering this action will cause a call to
undo()
on the active stack. The text of this action will always be the text of the command which will be undone in the next call toundo()
, prefixed byprefix
. If there is no command available for undo, if the group is empty or if none of the stacks are active, this action will be disabled.If
prefix
is empty, the default template “Undo %1” is used instead of prefix. Before Qt 4.8, the prefix “Undo” was used by default.See also
- PySide2.QtWidgets.QUndoGroup.indexChanged(idx)¶
- Parameters:
idx – int
- PySide2.QtWidgets.QUndoGroup.isClean()¶
- Return type:
bool
Returns the value of the active stack’s
isClean()
.If none of the stacks are active, or if the group is empty, this function returns
true
.See also
- PySide2.QtWidgets.QUndoGroup.redo()¶
Calls
redo()
on the active stack.If none of the stacks are active, or if the group is empty, this function does nothing.
See also
- PySide2.QtWidgets.QUndoGroup.redoText()¶
- Return type:
str
Returns the value of the active stack’s
redoText()
.If none of the stacks are active, or if the group is empty, this function returns an empty string.
See also
- PySide2.QtWidgets.QUndoGroup.redoTextChanged(redoText)¶
- Parameters:
redoText – str
- PySide2.QtWidgets.QUndoGroup.removeStack(stack)¶
- Parameters:
stack –
PySide2.QtWidgets.QUndoStack
Removes
stack
from this group. If the stack was the active stack in the group, the active stack becomes 0.See also
addStack()
stacks()
~QUndoStack()
- PySide2.QtWidgets.QUndoGroup.setActiveStack(stack)¶
- Parameters:
stack –
PySide2.QtWidgets.QUndoStack
Sets the active stack of this group to
stack
.If the stack is not a member of this group, this function does nothing.
Synonymous with calling
setActive()
onstack
.The actions returned by
createUndoAction()
andcreateRedoAction()
will now behave in the same way as those returned bystack
‘screateUndoAction()
andcreateRedoAction()
.See also
- PySide2.QtWidgets.QUndoGroup.stacks()¶
- Return type:
Returns a list of stacks in this group.
See also
- PySide2.QtWidgets.QUndoGroup.undo()¶
Calls
undo()
on the active stack.If none of the stacks are active, or if the group is empty, this function does nothing.
See also
- PySide2.QtWidgets.QUndoGroup.undoText()¶
- Return type:
str
Returns the value of the active stack’s
undoText()
.If none of the stacks are active, or if the group is empty, this function returns an empty string.
See also
- PySide2.QtWidgets.QUndoGroup.undoTextChanged(undoText)¶
- Parameters:
undoText – str
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.