Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
MyCommand Struct Reference

[0] More...

Inheritance diagram for MyCommand:
Collaboration diagram for MyCommand:

Public Member Functions

 MyCommand ()
void undo () override
 Reverts a change to the document.
void redo () override
 Applies a change to the document.
int id () const override
 Returns the ID of this command.
 MyCommand ()
void undo () override
 Reverts a change to the document.
void redo () override
 Applies a change to the document.
int id () const override
 Returns the ID of this command.
Public Member Functions inherited from QUndoCommand
 QUndoCommand (QUndoCommand *parent=nullptr)
 Constructs a QUndoCommand object with parent parent.
 QUndoCommand (const QString &text, QUndoCommand *parent=nullptr)
 Constructs a QUndoCommand object with the given parent and text.
virtual ~QUndoCommand ()
 Destroys the QUndoCommand object and all child commands.
QString text () const
 Returns a short text string describing what this command does; for example, "insert text".
QString actionText () const
void setText (const QString &text)
 Sets the command's text to be the text specified.
bool isObsolete () const
void setObsolete (bool obsolete)
virtual bool mergeWith (const QUndoCommand *other)
 Attempts to merge this command with command.
int childCount () const
const QUndoCommandchild (int index) const

Detailed Description

[0]

Definition at line 23 of file src_gui_util_qundostack.cpp.

Constructor & Destructor Documentation

◆ MyCommand() [1/2]

MyCommand::MyCommand ( )
inline

Definition at line 25 of file src_gui_util_qundostack.cpp.

Referenced by examples().

Here is the caller graph for this function:

◆ MyCommand() [2/2]

MyCommand::MyCommand ( )
inline

Definition at line 25 of file src_gui_util_qundostack.cpp.

Member Function Documentation

◆ id() [1/2]

int MyCommand::id ( ) const
inlineoverridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

QUndoStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), QUndoStack::push()

Reimplemented from QUndoCommand.

Definition at line 28 of file src_gui_util_qundostack.cpp.

◆ id() [2/2]

int MyCommand::id ( ) const
inlineoverridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

QUndoStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), QUndoStack::push()

Reimplemented from QUndoCommand.

Definition at line 28 of file src_gui_util_qundostack.cpp.

◆ redo() [1/2]

void MyCommand::redo ( )
inlineoverridevirtual

Applies a change to the document.

This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from QUndoCommand.

Definition at line 27 of file src_gui_util_qundostack.cpp.

◆ redo() [2/2]

void MyCommand::redo ( )
inlineoverridevirtual

Applies a change to the document.

This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from QUndoCommand.

Definition at line 27 of file src_gui_util_qundostack.cpp.

◆ undo() [1/2]

void MyCommand::undo ( )
inlineoverridevirtual

Reverts a change to the document.

After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from QUndoCommand.

Definition at line 26 of file src_gui_util_qundostack.cpp.

◆ undo() [2/2]

void MyCommand::undo ( )
inlineoverridevirtual

Reverts a change to the document.

After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from QUndoCommand.

Definition at line 26 of file src_gui_util_qundostack.cpp.


The documentation for this struct was generated from the following file: