Asynchronous event with QtConcurrent
I wanted to run a asynchronous event on my samson app (I wanted to make the molecule vibrate and still be able to use something else).
I did it using QtConcurrent tools, for this I had to change the content of CMakeLists.txt to add QtConcurrent library. It compiles fine but now my app is not visible anymore in SAMSON Debug. Is it because I changed CMakeLists.txt?
Thanks in advance
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
For example you declare in a header a
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); // make it repetitive
Then, when you want to start the animation you do:
animationTimer.start(20); // every 20 milliseconds
And when you want to stop the animation you do:
animate()slot, you perform one step of the vibration. The
QTimerwill 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,
thanks for your answer, I'll do that then.