On my mainwindow I have two Qpushbuttons: add object button and undo button.
When I click the add object button, it renders an OpenGL model, and I want it to render another model when I click the add button again. The Undo button should undo the last add-action.
How can I achieve this?
You’re confusing OpenGL with a scene graph. OpenGL does not maintain a scene of objects or geometry. I just draw’s things. If you change something, you’ve to redraw the whole thing from the scene data you maintain.
Undo/Redo become operations on your scene data. And after the operations on the scene you can use OpenGL do draw the scene.