Qt World Summit: Submit your Presentation

How to affect GUIs across threads

  • I'm currently working on a project that uses PortAudio, and I'm trying to use QwtPlot among others to graph various data for debugging, and I'm hoping to include similar things for the end user.
    All of the data processing happens on the low-latency audio thread, which needs to run at the highest speed possible, and as such thread-safe operations are not ideal, as they slow down the program enough to have a noticeable impact. Are there any methods for "queueing" changes across threads for such applications, or any other solutions?

    I've seen various references of QObjects for when threading is needed, but sadly for PortAudio the data is handled on a thread I cannot control.

  • Lifetime Qt Champion

    @Martmists said in How to affect GUIs across threads:

    Are there any methods for "queueing" changes across threads for such applications

    Of course: signals/slots with Qt::QueuedConnection connection type, see https://doc.qt.io/qt-5/qt.html#ConnectionType-enum. Qt::QueuedConnection is default when connecting signals/slots between different threads.
    Important rule: never change UI from other threads than UI thread. So, simply emit signals from your audio thread and connect these signals to slots in your UI thread where you then change the UI.

Log in to reply