How to start timers for multiple object
hello everyone, i made a gui in qt in which on mousepressevent a button object will be created evertytime on mouse click.when we will press mouse a button object will be created and on button i added a image (ship) will show.now on another pushbutton timer is calling and my ship will be move .its totally fine for single ship object.but when i am adding multiple ship on mouse click there r some problem with in timers.how i will make timer for multiple ship.any help will be appreciated...thanks in advance
welcome to devnet
You can use several instances of "QTimer":http://qt-project.org/doc/qt-5.0/qtcore/qtimer.html and connect to "timerEvent":http://qt-project.org/doc/qt-5.0/qtcore/qtimer.html#timerEvent slot This is gives you a "QTimeEvent":http://qt-project.org/doc/qt-5.0/qtcore/qtimerevent.html which helps you determining where it has been issued. Alternatively you can connect the timers already to different slots.
If I understand you, you want a single timer for multiple objects??
connect the timeout() signal of the timer to multiple slots of the objects. Then thy will all be called on the same time interval.
On the other hand, why not generate a QImage or QObject class that is created when a button is clicked? In that class overwrite the timerEvent.
That is an other solution.
Next time if you ask a question, maybe add a picture what you want to achieve. Or maybe code samples what is not working.