Qt::QueuedConnection from QML



  • 0 down vote favorite
    share [g+] share [fb] share [tw]

    I have C++ class emitting signal and QML slot. I need to execute slot in the same thread after program returns to the event loop.
    How can I achieve something like this?

    @Connections {
    target: box2dCppEngine
    onBulletCollided: box2dCppEngine.deleteObject(bullet)
    connectionType: Qt.QueuedConnection
    }
    @

    I need this because I can not execute deleteObject, while processing the collision, I need to do this after world step.



  • Maybe you could make deleteObject() itself use deleteLater() ?



  • Maybe, but this forces me to make all my objects derived from QObject, which I don't like.


  • Moderators

    bq. Maybe, but this forces me to make all my objects derived from QObject, which I don’t like.

    Why don't you like it? Any particular reasons? QObjects are pretty ubiquitous. :-)



  • Or make box2dCppEngine.deleteObject() add the object to a list and trigger a 0-timer to delete the objects in the list.


Log in to reply
 

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