Qt has a pretty nice QUndoStack which you can use in your application, but unfortunately it does not integrate at all with the QLineEdit widget.
QLineEdit implements it's own undo stack using a completely different design that has specific knowledge about how QLineEdit works. The shitty thing about this is that the Ctrl-Z keyboard undo and the edit->undo menu do not refer to the same thing, so each will give different results. This is a terrible user experience and there should be a better way to handle it.
The only suggestion I've gotten is to implement my own undo menu code that checks to see if a QLineEdit has focus, and if it does, call it's undo rather than the application undo. Undoubtedly QLineEdit is not the only widget with this flaw, so that undo code will get pretty ugly. Any then I'd also have to catch the Ctrl-Z event in each QLineEdit and somehow make it call the application undo when appropriate.
Oh, and now that I think about it, you can never know the proper order because the commands are on different queues and you have no way to know which command was put on one of the queues last. What a mess. Maybe there's a way to disable the undo handling in QLineEdit, but I haven't found that yet if it's there.
Wow, this has been a complaint since 2011: QTBUG-16774
No comments:
Post a Comment