Detect QGraphicsScene changes
-
Hi,
I am currently developing a small graphic application. It consist on a QMainWindow with a QGraphicsScene as centralwidget !
I want to implement a function that, when the application is closed, will check if the graphicsScene modifications (add/delete/move graphics items) are saved to an XML file. I know this function:@changed ( const QList<QRectF> & region )@
I don't know how to use it ! It sometimes work and sometimes don't !
any idea ? -
This is not a function, it is a signal. Add a bool sceneChanged to your main window, connect the changed() signal to a slot that sets the sceneChanged to true, and when closing the application, check if the scene has changed, and if so - serialize it to disk in a format of your choice.
I'd personally prefer JSON over XML - it is faster to parse and more space efficient. Also easier on the eyes in case you need to modify it manually.