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 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 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": and connect to "timerEvent": slot This is gives you a "QTimeEvent": which helps you determining where it has been issued. Alternatively you can connect the timers already to different slots.

  • Oke,
    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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.