How to rename the QUndoCommand in the QWebPage undoStack?
-
I'm able to successfully access the QWebPage undoStack (QUndoStack) and obtain many of the undoStack parameters such as count, last index, and text as follows:
@
qDebug()<<"undo size: " <<page()->undoStack()->count();
int cindex = page()->undoStack()->index();
qDebug()<<"command name:"<<page()->undoStack()->text(cindex);
@The problem I found was that that the text is always empty for common commands like cut or paste. I had hoped to fix this by setting the QUndoCommand text directly. For example:
@
page()->undoStack()->command(cindex)->setText(QString("cut"));
@I thought this should work because I'm only using a const pointer but when I try it I get the error message:
passing 'const QUndoCommand' as 'this' argument of 'void QUndoCommand::setText(const QString&)' discards qualifiers
I have tried a number things to try and rename the command so I can see the undo sequence using QUndoView but none have been successful. Hopefully someone has a suggestion I can use.
-
the only thing i see you can do is this ugly trick:
@
QUndoCommand* cmd = const_cast<QUndoCommand*>( page()->undoStack()->command(cindex) );
cmd->setText("cut");
@ -
Gene thanks for the suggestion but unfortunately it crashes the program. The cast seems to work but when I use
@cmd->setText("Cut");@to set the text the program crashes.
-
please post the stack trace.