PySide6.QtGui.QUndoGroup¶
- class QUndoGroup¶
- The - QUndoGroupclass is a group of- QUndoStackobjects. More…- Synopsis¶- Methods¶- def - __init__()
- def - activeStack()
- def - addStack()
- def - canRedo()
- def - canUndo()
- def - isClean()
- def - redoText()
- def - removeStack()
- def - stacks()
- def - undoText()
 - Slots¶- def - redo()
- def - setActiveStack()
- def - undo()
 - Signals¶
- def - canRedoChanged()
- def - canUndoChanged()
- def - cleanChanged()
- def - indexChanged()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - 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. - QUndoGroupis a group of- QUndoStackobjects, one of which may be active. It has an- undo()and- redo()slot, which calls- undo()and- redo()for the active stack. It also has the functions- createUndoAction()and- createRedoAction(). The actions returned by these functions behave in the same way as those returned by- createUndoAction()and- createRedoAction()of the active stack.- Stacks are added to a group with - addStack()and removed with- removeStack(). A stack is implicitly added to a group when it is created with the group as its parent QObject.- 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 with- setActiveStack(), and is returned by- activeStack().- 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 - QUndoGroupis also useful in conjunction with QUndoView. If a QUndoView is set to watch a group using QUndoView::setGroup(), it will update itself to display the active stack.- Creates an empty - QUndoGroupobject with parent- parent.- See also - 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 - activeStackChanged(stack)¶
- Parameters:
- stack – - QUndoStack
 
 - This signal is emitted whenever the active stack of the group changes. This can happen when - setActiveStack()or- setActive()is called, or when the active stack is removed form the group.- stackis the new active stack. If no stack is active,- stackis 0.- See also - addStack(stack)¶
- Parameters:
- stack – - QUndoStack
 
 - Adds - stackto 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 parent QObject in- QUndoStack(). In this case, the stack is deleted when the group is deleted, in the usual manner of QObjects.- See also - removeStack()- stacks()- QUndoStack()- 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 - canRedoChanged(canRedo)¶
- Parameters:
- canRedo – bool 
 
 - This signal is emitted whenever the active stack emits - canRedoChanged()or the active stack changes.- canRedois the new state, or false if the active stack is 0.- See also - 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 - canUndoChanged(canUndo)¶
- Parameters:
- canUndo – bool 
 
 - This signal is emitted whenever the active stack emits - canUndoChanged()or the active stack changes.- canUndois the new state, or false if the active stack is 0.- See also - cleanChanged(clean)¶
- Parameters:
- clean – bool 
 
 - This signal is emitted whenever the active stack emits - cleanChanged()or the active stack changes.- cleanis the new state, or true if the active stack is 0.- See also - createRedoAction(parent[, prefix=""])¶
 - Creates an redo - QActionobject with parent- parent.- 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 to- redo(), prefixed by- prefix. 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 - prefixis empty, the default template “Redo %1” is used instead of prefix. Before Qt 4.8, the prefix “Redo” was used by default.- See also - createUndoAction(parent[, prefix=""])¶
 - Creates an undo - QActionobject with parent- parent.- 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 to- undo(), prefixed by- prefix. 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 - prefixis empty, the default template “Undo %1” is used instead of prefix. Before Qt 4.8, the prefix “Undo” was used by default.- See also - indexChanged(idx)¶
- Parameters:
- idx – int 
 
 - This signal is emitted whenever the active stack emits - indexChanged()or the active stack changes.- idxis the new current index, or 0 if the active stack is 0.- See also - 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 - 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 - 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 - redoTextChanged(redoText)¶
- Parameters:
- redoText – str 
 
 - This signal is emitted whenever the active stack emits - redoTextChanged()or the active stack changes.- redoTextis the new state, or an empty string if the active stack is 0.- See also - removeStack(stack)¶
- Parameters:
- stack – - QUndoStack
 
 - Removes - stackfrom this group. If the stack was the active stack in the group, the active stack becomes 0.- See also - addStack()- stacks()- ~QUndoStack()- setActiveStack(stack)¶
- Parameters:
- stack – - 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()on- stack.- The actions returned by - createUndoAction()and- createRedoAction()will now behave in the same way as those returned by- stack's- createUndoAction()and- createRedoAction().- See also - stacks()¶
- Return type:
- .list of QUndoStack 
 
 - Returns a list of stacks in this group. - See also - 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 - 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 - undoTextChanged(undoText)¶
- Parameters:
- undoText – str 
 
 - This signal is emitted whenever the active stack emits - undoTextChanged()or the active stack changes.- undoTextis the new state, or an empty string if the active stack is 0.- See also