每秒轮询一次QT中的变量 [英] Polling a variable in QT once every second

查看:350
本文介绍了每秒轮询一次QT中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究多线程图像处理应用程序.我添加了基于QT的GUI,目的是更改一些我必须进行大量试验的参数,而不是每次启动程序或键入时都从设置文件中加载所有参数.我也想GUI显示来自每个线程的一些基本信息,因此我可以对其进行监视.我目前有在设置的图像处理线程之间传递信息的线程安全方法,并且我希望有一种方法大约每秒钟从QT线程中轮询一些此信息,以便在UI上显示一些反馈.

I'm working on a multithreaded image processing application. I added on a GUI based on QT for the purposes of changing some parameters that I have to experiment with a lot rather than loading them all from a settings file each time I start the program or having to type them in. I would also like the GUI to display some basic information from each of the threads so I can monitor them. I currently have thread safe methods of passing information between the image processing threads set up and I would like a way to poll some of this information from the QT thread approximately every second so I can display some feedback on the UI.

我的要求是,我不需要将QT特定的代码合并到图像处理线程中以更新UI.我宁愿让UI线程轮询我当前用于在线程之间传递信息的方法.我希望代码库中的图像处理部分独立存在,而不必依赖QT来运行.我将如何查询全局可用的功能来更新QT UI?

My requirement is that I don't want to have to incorporate QT specific code into the image processing threads to update the UI. I would rather have the UI thread poll the methods I currently use to pass information between the threads. I want the image processing portion of my codebase to stand alone and not have to depend on QT to run. How would I poll a globally available function to update the QT UI?

推荐答案

或者在Qt5和C ++ 11中,您可以直接连接到lambda.尽管使用插槽可以确保在连接到另一个线程中生活的对象时获得排队连接.

Or in Qt5 and C++11 you can directly connect to a lambda. Although using a slot will ensure you get queued connections in case you are connecting to an object living in another thread.

这篇关于每秒轮询一次QT中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆