Qt信号/插槽和线程 [英] Qt Signals/Slots and Threads

查看:322
本文介绍了Qt信号/插槽和线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的GUI编程和多线程。我正在创建一个实时应用程序,从我的车接收信息,并以一些有意义的方式呈现。我的应用程序被布局为3个线程,GUI(主线程),渲染线程和硬件comm线程。在渲染和硬件线程之间是一个共享的环形缓冲区。在渲染中,我创建了一个定时器,以便它每秒绘制新的界面20次。我想线程通知主线程有一个新的屏幕可用,我在想一个信号/槽的方法将工作最好的为此。这得到我的问题。当我的渲染调用一个槽,说Screen_Avalable,这是在主线程中的主窗口对象,这个槽/方法是否在我的工作线程或主线程处理?

I'm new to GUI programming and multithreading. I am in the process of creating a real-time app that receives information from my car and renders it in some meaningful way. My app is layed out as 3 threads, the GUI (main thread), the rendering thread and the hardware comm thread. Inbetwen the the render and the hardware threads is a shared ring buffer. In the render I have created a timer so that it draws the new interface 20 times a second. I would like the thread to notify the main thread that there is a new screen available and I was thinking a signal/slots method would work the best for this. This gets down to my question. When my render calls a slot, say Screen_Avalable, that is in my main window object in the main thread, does this slot/method get processed in my worker thread or the main thread?

推荐答案

默认情况下,它在主线程中处理,但请参阅

It gets processed in the main thread by default, but see this guide for more information.

这篇关于Qt信号/插槽和线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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