Painter example Undo/Ctrl-Z

Heads up! You've already completed this tutorial.

Paapu | 2020-05-10 20:21:13 UTC | #1

I tried to figure out how to cancel a part of a drawing (using subsequent ctrl-Z or something). Would this be doable? (I could not make it...)


martin | 2020-05-10 20:22:07 UTC | #2

Hi @Paapu it should be! One simple way would be to take a snapshot of the current pixmap canvas on every mouse down (start drawing) and store this in a temporary variable. Then when Ctrl-Z is pressed (detected using a QAction) you can copy that back over the current canvas.


Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt5
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Painter example Undo/Ctrl-Z was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.