Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

threading strategy question



  • I use RtMidi for MIDI I/O support in my QtQuick application (https://github.com/thestk/rtmidi). I also use qmlmidi to easily use RtMidi from QML (https://github.com/jarnoh/qmlmidi).

    Now I would like to move the MIDI I/O operations to another thread(s), because in my application, the graphical knob updates can become slow when MIDI traffic is high and when there is a lot of pre-post MIDI processing to do.

    What is the best approach? I've read the QThread documentation, but it is not quite obvious which strategy I should use. I'm trying to think it through.

    I suppose I need a class that inherits from QAbstractListModel, which I can expose to QML via the root context, to provide data values to my on-screen graphical knobs. I guess this class should be instatiated in main() and root context set there. It is in the main thread.

    Then this class would have its model populated from the MIDI I/O results. Maybe I would have a "MIDI In" Worker object and also a "MIDI Out" Worker object, and each one would have its own Controller class with its own QThread.

    Finally, the object of my class which is derived from AbstractListModel model would need to interact with the Worker objects for MIDI In and Out via signals/slots.

    Is this approach reasonable?


  • Qt Champions 2017

    You are trying to create the MIDI objects in separate thread & trying to push the data using the signal/slot to model. This approach can be taken.


Log in to reply