Hi Laetitia,
for efficiency reasons, the data graph is not thread-safe, so there might be issues when modifying the document from several distincts threads (e.g. in the history). So, when we want to do this type of things, we use a QTimer
.
For example you declare in a header a QTimer
:
QTimer animationTimer;
and a slot:
public slots:
void animate();
and in your source code (for example in the constructor), you connect the timer to a slot that will perform one update of the system:
connect(&animationTimer, SIGNAL(timeout()), this, SLOT(animate()));
animationTimer.setSingleShot(false);
Then, when you want to start the animation you do:
animationTimer.start(20);
And when you want to stop the animation you do:
animationTimer.stop();
In your animate()
slot, you perform one step of the vibration. The QTimer
will intersperse calls to your animate()
function as regularly as possible, and SAMSON will still be able to process other events (keyboard, mouse, etc.).
Hope this helps,
Stephane