Pass custom data from UI thread to SG thread in correct order

  • I'm trying to inherit QQuickItem and do some custom Scene Graph rendering. The update() method called in the UI thread will schedule a paint event in the SG render thread that will call the the updatePaintNode(). Is there a built-in mechanism/technique that I can use to pass some custom data from UI thread that will be queued and passed to the item and be available with right order during updatePaintNode() execution? That will be handy, since if I don't have this mechanism I must implement my queue protected by lock in every custom QQuickItem that needs this pattern (lock itself is not enough since I don't want to miss any signal in the UI thread).

  • A quote from the docs:
    The main thread is blocked while this function is executed so it is safe to read values from the QQuickItem instance and other objects in the main thread.

  • @jpnurmi Interesting, thank you. Though I don't like much this approach chosen for QtQuick in general since this means making the UI thread starving a little bit while it could run safely using data on different storage. I found also the mechanism you are talking well described in this document.

    I also just found QQuickFramebufferObject that can use an approach similar to what I was describing by implementing a separate QQuickFramebufferObject::Renderer class that is invoked to synchronize content on the item and perform actual rendering on a FBO.

Log in to reply

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