In Qt, How to prevent rendering from killing other periodic functions?

Posted on 2012-08-19
Last Modified: 2012-08-26
(I see there are "Top QT Experts" to the right -- but is there a zone??)

Hello, we are fairly new to QT, and writing an embedded QT application (using QTQuick) that talks to a serial port (needs to send messages at a constant rate) and renders some complex, scrollable displays.

We have found that the user can use the display (for example, scrolling the chart) in a way that makes the serial messages stop for a bit. We believe that the scrolling/re-rendering is starving the timer that is driving the serial messages momentarily. Currently this is driven by a QTimer and a signal/slot connection.

We need to revise to ensure that the rendering of the display, no matter how complex, cannot prevent the sending of a serial message. What's the best way to do this in a QT application? We can make the display simpler, but this would simply reduce the chances of this -- if there is enough data to render this it seems this is always possible with our current approach -- we want this to not be possible.

I can imagine answers ranging from setting priority flags (if any) in the QT framework, to re-sourcing our serial comm from the QT Timer to something more deterministic, to making our application multithreaded (I hope it doesn't get this drastic, but we will do this if it's the only way to ensure serial cant be interrupted).

Any thoughts from experienced QT folks are very appreciated.
Question by:RonMexico
    LVL 7

    Expert Comment

    He He he ,... Making it multitrheaded is not Drastic :)
    Blv me that is the best way to keep GUI thread separate from your functional processing thread.  in my experience separating GUI thread (which is always rendering thread) is not more than an hour job.
    But dont forget to communicate between GUI thread and worker thread using signal and slot this is best non blocking way , you may also use PostMessge but i think former would be better.

    Best of luck.

    Author Comment

    Hm, I am presuming it would be drastic because UI calls a lot of functions of the backend directly, would have to rewrite ALL of these to protect using sync objects, wouldn't we?  Any shortcuts here?

    I'll do a little research, but does QT multithreading allow us to prioritize relatively, so that rendering can never starve out the serial?

    Thanks for the help.
    LVL 7

    Accepted Solution

    i can understand if there are really several calls between GUI and worker then this could be little time consuming to separate it, But dont you think in such situation multithreading should have been considered really at design time?
    if GUI is having so much dependency on worker thread then in all Framework/toolkit the best way to go for is only and only this (mulitithread).

    and Yes you can prioritize it with Qt. I again emphasis on one thing communication between these thread is damn important, choose signal slot is the best way to go.

    Best fo Luck

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now