如何在不同的Qt线程中调用GUI元素? [英] How to call GUI elements in different Qt threads?

查看:171
本文介绍了如何在不同的Qt线程中调用GUI元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中一个线程(不是主线程)需要访问GUI的元素(发送单击动作,显示消息框等).我在python和Qt中工作,也知道在非主线程中是不可能的. 有办法吗?我的意思是将要在线程中执行的操作发送到主线程.

I have an application in which a thread (not main thread) needs access to the GUI's elements (send a click action, show a message box, etc). I am working in python and Qt and also know that it is not possible when in not main thread. Is there a way to do it? I mean to send the action that I want to do in the thread to the main thread.

推荐答案

以下是有关如何使用Qthread的很好的教程:

Here is a good tutorial on how to use Qthread: http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ . This will show how to call the GUI elements in different and custom threads. Hope this helps.

这篇关于如何在不同的Qt线程中调用GUI元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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