Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to start timers for multiple object
Forum Updated to NodeBB v4.3 + New Features

How to start timers for multiple object

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prabhat
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        Oke,
        If I understand you, you want a single timer for multiple objects??
        solution:
        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.
        Greetz
        Jeroen

        Greetz, Jeroen

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved