[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2012-08-19
Medium Priority
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
  • 2

Expert Comment

ID: 38309534
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

ID: 38309583
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.

Accepted Solution

irfan_omair earned 2000 total points
ID: 38315918
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

834 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