Nominate our 2022 Qt Champions!

QTimer in QQuickItem’s updatePaintNode()

    From this blog, I understand that threaded renderer is used by default on mac.

    Is it possible to start a timer in QQuickItem's updatePaintNode() on mac? During updatePaintNode, on mac we are currently on the scene graph renderer thread with the scene graph's OpenGL context current.

    @QSGNode *AAA::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
    m_timer = new(std::nothrow) QTimer(0);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(pulse_()),Qt::DirectConnection);
    // Draw stuff

    I want the timer to be executed continuously and like to destroy it in my class's destructor.. I am not sure how the render thread's event loop works. With the above code, timeout events stop once drawing completes and then re-starts when update occurs the next time.

    Basically , I am using a custom library for drawing an OpenGL component. At certain conditions, if the drawing and GUI threads are different, the library blocks the GUI thread and waits for a pulse event to unblock the UI thread.
    I am trying to send this pulse event from a timer that is running in the renderer thread.

    I am trying to figure out the best place to place my timer in multithreaded environment. Would appreciate any help on this.

Log in to reply