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

Real-Time Plotting



  • Hey guys,

    i just need to implement real time plotting of data which is distributed over UDP.
    Now i want to ask if the Model-View-Controller principle is the right tool for it? Seems to be to heavy...

    Maybe you have some good examples for me. Thank you!



  • @MaxBec Take a look at the QML Oscilloscope example (https://doc.qt.io/qt-5/qtcharts-qmloscilloscope-example.html), and see if that can help you!

    I did something similar using QUdpSockets to get real time data (from UDP socket data) and show in a linechart in QML.



  • But this doesn't use the Model View principle. Is this principle suitable for a real time application?



  • @MaxBec First, define "realtime". What is your absolute minimal determinism. Realtime requires time constraints are guaranteed to be met. So say you need 60 frames per second. So that means you have to produce a frame every 17 mS. That would be your constraint. Now, build a model class and attach to a view. Push the data to the model and consume it. Is it fast enough to meet the 17 mS requirement? Then attach that to a graph. Repeat the test. Test this over network as well.

    I would start with the "Scene Graph - Graph" example. It does not use model view. I have built my own custom version of this example that eats data from an audio source (using Gamma library). It displayed this data in "realtime" I suppose. It was not over a network though.



  • There was a similar question in another thread about UDP and passing to QML in that case. I would probably recommend doing the same thing. Create a handling class for the UDP anagrams and massage them until you have the data you need your UI to display. When that is ready expose the data through a property or signal to notify the UI it’s time to redraw the chart.

    In my case I got UDP data over a socket from an MCU in 1, 10 or 100Hz intervals. I didn’t stumble uponany realtime problems there. But that all depends. What is real time? What hardware etc you have. What is time even? 😉

    It might also be different requirements on the UI frame rate and the update rate on the UDP data. 60FPS for a UI is nice, but refreshing “data” 60 times per seconds might be impossible to comprehend.


Log in to reply