Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QUndoGroup Class

TheQUndoGroup class is a group ofQUndoStack objects.More...

Header:#include <QUndoGroup>
Since: Qt 4.2
Inherits:QObject

Public Functions

QUndoGroup(QObject * parent = 0)
~QUndoGroup()
QUndoStack *activeStack() const
voidaddStack(QUndoStack * stack)
boolcanRedo() const
boolcanUndo() const
QAction *createRedoAction(QObject * parent, const QString & prefix = QString()) const
QAction *createUndoAction(QObject * parent, const QString & prefix = QString()) const
boolisClean() const
QStringredoText() const
voidremoveStack(QUndoStack * stack)
QList<QUndoStack *>stacks() const
QStringundoText() const
  • 29 public functions inherited fromQObject

Public Slots

voidredo()
voidsetActiveStack(QUndoStack * stack)
voidundo()
  • 1 public slot inherited fromQObject

Signals

voidactiveStackChanged(QUndoStack * stack)
voidcanRedoChanged(bool canRedo)
voidcanUndoChanged(bool canUndo)
voidcleanChanged(bool clean)
voidindexChanged(int idx)
voidredoTextChanged(const QString & redoText)
voidundoTextChanged(const QString & undoText)

Additional Inherited Members

  • 1 property inherited fromQObject
  • 7 static public members inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

TheQUndoGroup class is a group ofQUndoStack objects.

For an overview of the Qt's undo framework, see theoverview.

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 callsQUndoStack::undo() andQUndoStack::redo() for the active stack. It also has the functionscreateUndoAction() andcreateRedoAction(). The actions returned by these functions behave in the same way as those returned byQUndoStack::createUndoAction() andQUndoStack::createRedoAction() of the active stack.

Stacks are added to a group withaddStack() 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 callingQUndoStack::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 usingaddStack(), 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.

AQUndoGroup is also useful in conjunction withQUndoView. If aQUndoView is set to watch a group usingQUndoView::setGroup(), it will update itself to display the active stack.

Member Function Documentation

QUndoGroup::QUndoGroup(QObject * parent = 0)

Creates an emptyQUndoGroup object with parentparent.

See alsoaddStack().

QUndoGroup::~QUndoGroup()

Destroys theQUndoGroup.

QUndoStack * QUndoGroup::activeStack() const

Returns the active stack of this group.

If none of the stacks are active, or if the group is empty, this function returns 0.

See alsosetActiveStack() andQUndoStack::setActive().

[signal]void QUndoGroup::activeStackChanged(QUndoStack * stack)

This signal is emitted whenever the active stack of the group changes. This can happen whensetActiveStack() orQUndoStack::setActive() is called, or when the active stack is removed form the group.stack is the new active stack. If no stack is active,stack is 0.

See alsosetActiveStack() andQUndoStack::setActive().

void QUndoGroup::addStack(QUndoStack * stack)

Addsstack 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::QUndoStack(). In this case, the stack is deleted when the group is deleted, in the usual manner ofQObjects.

See alsoremoveStack(),stacks(), andQUndoStack::QUndoStack().

bool QUndoGroup::canRedo() const

Returns the value of the active stack'sQUndoStack::canRedo().

If none of the stacks are active, or if the group is empty, this function returns false.

See alsocanUndo() andsetActiveStack().

[signal]void QUndoGroup::canRedoChanged(bool canRedo)

This signal is emitted whenever the active stack emitsQUndoStack::canRedoChanged() or the active stack changes.

canRedo is the new state, or false if the active stack is 0.

See alsoQUndoStack::canRedoChanged() andsetActiveStack().

bool QUndoGroup::canUndo() const

Returns the value of the active stack'sQUndoStack::canUndo().

If none of the stacks are active, or if the group is empty, this function returns false.

See alsocanRedo() andsetActiveStack().

[signal]void QUndoGroup::canUndoChanged(bool canUndo)

This signal is emitted whenever the active stack emitsQUndoStack::canUndoChanged() or the active stack changes.

canUndo is the new state, or false if the active stack is 0.

See alsoQUndoStack::canUndoChanged() andsetActiveStack().

[signal]void QUndoGroup::cleanChanged(bool clean)

This signal is emitted whenever the active stack emitsQUndoStack::cleanChanged() or the active stack changes.

clean is the new state, or true if the active stack is 0.

See alsoQUndoStack::cleanChanged() andsetActiveStack().

QAction * QUndoGroup::createRedoAction(QObject * parent, constQString & prefix = QString()) const

Creates an redoQAction object with parentparent.

Triggering this action will cause a call toQUndoStack::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.

Ifprefix is empty, the default template "Redo %1" is used instead of prefix. Before Qt 4.8, the prefix "Redo" was used by default.

See alsocreateUndoAction(),canRedo(), andQUndoCommand::text().

QAction * QUndoGroup::createUndoAction(QObject * parent, constQString & prefix = QString()) const

Creates an undoQAction object with parentparent.

Triggering this action will cause a call toQUndoStack::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.

Ifprefix is empty, the default template "Undo %1" is used instead of prefix. Before Qt 4.8, the prefix "Undo" was used by default.

See alsocreateRedoAction(),canUndo(), andQUndoCommand::text().

[signal]void QUndoGroup::indexChanged(int idx)

This signal is emitted whenever the active stack emitsQUndoStack::indexChanged() or the active stack changes.

idx is the new current index, or 0 if the active stack is 0.

See alsoQUndoStack::indexChanged() andsetActiveStack().

bool QUndoGroup::isClean() const

Returns the value of the active stack'sQUndoStack::isClean().

If none of the stacks are active, or if the group is empty, this function returns true.

See alsosetActiveStack().

[slot]void QUndoGroup::redo()

CallsQUndoStack::redo() on the active stack.

If none of the stacks are active, or if the group is empty, this function does nothing.

See alsoundo(),canRedo(), andsetActiveStack().

QString QUndoGroup::redoText() const

Returns the value of the active stack'sQUndoStack::redoText().

If none of the stacks are active, or if the group is empty, this function returns an empty string.

See alsoundoText() andsetActiveStack().

[signal]void QUndoGroup::redoTextChanged(constQString & redoText)

This signal is emitted whenever the active stack emitsQUndoStack::redoTextChanged() or the active stack changes.

redoText is the new state, or an empty string if the active stack is 0.

See alsoQUndoStack::redoTextChanged() andsetActiveStack().

void QUndoGroup::removeStack(QUndoStack * stack)

Removesstack from this group. If the stack was the active stack in the group, the active stack becomes 0.

See alsoaddStack(),stacks(), andQUndoStack::~QUndoStack().

[slot]void QUndoGroup::setActiveStack(QUndoStack * stack)

Sets the active stack of this group tostack.

If the stack is not a member of this group, this function does nothing.

Synonymous with callingQUndoStack::setActive() onstack.

The actions returned bycreateUndoAction() andcreateRedoAction() will now behave in the same way as those returned bystack'sQUndoStack::createUndoAction() andQUndoStack::createRedoAction().

See alsoQUndoStack::setActive() andactiveStack().

QList<QUndoStack *> QUndoGroup::stacks() const

Returns a list of stacks in this group.

See alsoaddStack() andremoveStack().

[slot]void QUndoGroup::undo()

CallsQUndoStack::undo() on the active stack.

If none of the stacks are active, or if the group is empty, this function does nothing.

See alsoredo(),canUndo(), andsetActiveStack().

QString QUndoGroup::undoText() const

Returns the value of the active stack'sQUndoStack::undoText().

If none of the stacks are active, or if the group is empty, this function returns an empty string.

See alsoredoText() andsetActiveStack().

[signal]void QUndoGroup::undoTextChanged(constQString & undoText)

This signal is emitted whenever the active stack emitsQUndoStack::undoTextChanged() or the active stack changes.

undoText is the new state, or an empty string if the active stack is 0.

See alsoQUndoStack::undoTextChanged() andsetActiveStack().

© 2016 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 theGNU 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.


[8]ページ先頭

©2009-2025 Movatter.jp