Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QUndoStack with dropdown
I want to implement a undo button that shows a list of undo actions to choose from. For example, like in Microsoft Office where I can choose from a list of actions. I can directly jump to the past 10th action instead of clicking undo button 10 times.
In the Qt tutorial, only QUndoView usage with an external window.
Any idea I can do a similar thing without an extra window but with a dropdown?
Any examples that someone can point me to?
eyllanesc last edited by
@vijaychsk From what I understand you want to implement the same example from the tutorial but instead of seeing the QUndoView you want a QComboBox. I am right?
artwaw last edited by
@vijaychsk There is nothing that can stop you, I think. I never did it myself but I think it is entirely doable - you just add actions descriptions and index to the combo box and then push them to the stack. To get the action back you use that stored index. Grouping would also need to be implemented.
So, in theory, you'd just need to reimplement undo view using the stack as a store for undo actions.
You would need to implement your own model to set on the QComboBox. The one used by QUndoView is implemented beside the class implementation.
Something like this.
JonB last edited by JonB
You would need to implement your own model to set on the QComboBox.
Given what @SGaist is pointing it out here, you would have to write some code to replicate the functionality. Using your button to icon to "pop up" a
QUndoViewin some shape or form sounds like less work than utilising a
QComboBox. You might want to bear that in mind.