Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get notified when a QTextEdit get a new Undo item

my widget contains lots of QTextEdit controls. Actually all these QTextEdits are installed as item widgets for a QTreeWidget. all these controls are editable in place.

So, I need to implement a unified "undo stack", process control + "Z/Y" in my widget instead of each QTextEdit control. For this I have to take a record whenever a certain QTextEdit make a new undo item. So when I press control+Z, it will undo a QTextEdit control's editing(by invoking its undo() method), press again probably will undo another QTextEdit control's editing(by invoking its undo() method).

But when searched through the document,I found no such signal that notifies me that a new undo item is made for a QTextEdit. And I have no idea about the undo policy of a QTextEdit, sometime multiple keypress was compressed into one single undo item, so using a keypress eventfilter and record my own QUndoCommand probably not a good idea, not mentioned that QTextEdit provide its own convenient method undo()/redo().

How can I get arround this?

like image 591
miguel Avatar asked Dec 06 '25 13:12

miguel


1 Answers

I guess QTextDocument::undoCommandAdded is the signal you're looking for.

like image 162
cloose Avatar answered Dec 08 '25 05:12

cloose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!