[Qt-interest] accessing Undo information for QTextDocument

me mutschae at gmail.com
Tue Oct 13 11:30:52 CEST 2009


mh two years and the next developer is missing this feature:
i'd like to go even further:

qal[0] = textedit->getUndoStack();
textedit->setText(newtext1);
...
newtext1 = textedit->getText()
qal[1] = textedit->getUndoStack();
...
textedit->setText(newtext0);
textedit->setUndoStack(qal[0]);
...

-- effectively allowing a single textedit to swap the undo buffers.
i'd like to use this for a simple editor that changes the datasource
when selecting a different file in a tree left to the qtextedit

so far i just found the option to disable the undo feature and hook in
document::contentsChange to create the undostack myself.

anyone has a different way?

peace:m


On Sat, Oct 6, 2007 at 12:34 PM, Jonathan Kew <jonathan_kew at sil.org> wrote:
> I'd like to be able to dynamically update the text of the Undo and Redo menu
> items to indicate the specific action to be undone or redone in a QTextEdit
> widget. (E.g., "Undo Typing", "Redo Paste", etc.) As well as the standard
> Edit operations, my application has functions such as "Replace All", "Indent
> Block", etc., that should have custom Undo text shown in the menu items.
>
> However, I can't find methods to access the QTextDocument's undo stack or
> commands, either to retrieve the command text for my menu item, or to set
> the command text to be assigned to a custom change made through a
> QTextCursor. As a simple example, I expected to be able to say something
> like
>
>  void MyDocument::editMenuAboutToShow()
>  {
>    undoAction->setText(tr("Undo ") +
> textEdit->document()->undoStack()->undoText());
>    redoAction->setText(tr("Redo ") +
> textEdit->document()->undoStack()->redoText());
>  }
>
> or simply connect a slot to the undoTextChanged and redoTextChanged signals
> from the document's QUndoStack, but there is no undoStack() accessor on
> QTextDocument.
>
> Is there a straightforward solution to this that I'm overlooking?
>
> Jonathan
>
> --
> To unsubscribe - send a mail to qt-interest-request at trolltech.com with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>




More information about the Qt-interest-old mailing list