[Solved] QUndoStack: created actions permanently disabled
-
Hello.
I have a very strange problem, and it is probably due to me being stupid. But I have been looking around for hours, and now I give in.I have an application that uses Qts Undo framework. I have a QUndoGroup (with stacks) and a QUndoStack, separately.
I create some actions to include in menus, via "createRedoAction":http://qt-project.org/doc/qt-5.1/qtwidgets/qundostack.html#createRedoAction etc.
All of the actions are created successively, but only the ones created by the QUndoGroup are actually usable, the other ones stay deactivated even though the clean-state of the stack changes.I don't explicitly disable the actions, and I tried using the single UndoStack while leaving out the UndoGroup. Still, the actions of the stack never activate. (Of course I push commands onto the stack.)
Does anybody know of any beginner mistakes I could have made? The code is really huge, so I can't post it here.
Looking forward to any kind of hint. Thanks in advance. :)
-
After more tedious testing it seems like the QUndoStack is fully working. But the actions it created are initially disabled and they do not properly work. They don't react to state changes at all - and I checked these changes out manually, they do work as intended.
I even checked the sourcecode for QUndoStack and the relevant functions are identical to the ones in QUndoGroup.cpp.
If I try to manually add the connections, that doesn't change anything either. The actions created by this specific QUndoStack just don't react to anything at all.
Any ideas? I'll bang my head against a wall and give up for today, I guess. :(
-
I finally found the problem. A typo. I looked at the code a thousand times, and I still didn't see it.
@QAction *Act_Redo = widget->createRedoAction(this, tr("Redo"));
EditMenu->addAction(Act_Redo);QAction *Act_Undo= widget->createRedoAction(this, tr("Undo"));
EditMenu->addAction(Act_Undo);@
I used the redo-function twice, so the undo-button understandably never got enabled and the whole undostack wasn't accessible to the user.Shame on me.