[翻译] PySide6.QtCore.Qt.ConnectionType
翻译 (自用,不保证对)
PySide6.QtCore.Qt.ConnectionType
这个 enum 描述了 signals 和 slots 连接(connection) 的类型. 在一些特殊情况, 它决定了信号传递到插槽时的方式,比如 即时的(immediately)或 队列的(queued for delivery at a later time).
| Constant | Description |
|---|---|
| Qt.AutoConnection | 默认方式,槽在信息号发送者的线程执行动作。(Default) If the receiver lives in the thread that emits the signal, is used. Otherwise, is used. The connection type is determined when the signal is emitted. |
| Qt.DirectConnection | 槽立即在发送信号的线程,执行动作. |
| Qt.QueuedConnection | 槽等到接收者的线程激活时,在接收者的线程内执行动作. |
| Qt.BlockingQueuedConnection | 与上一个相同,不同在于,发送者的线程会阻塞(blocks),等待槽执行动作返回(returns). 注意:发送者和接收者不能在同一个线程,否则,线程会锁死(deadlock). |
| Qt.UniqueConnection | 这个类型和以上的类型组合使用,用 OR 连接. 当这个类型被使用时, 如果这个信息与指定的槽已经建立了连接,connect() 不会有作用 (,比如, 同一个信号,重复连接同一个槽). 在Qt 4.6被引入. |
| Qt.SingleShotConnection | 这个类型和以上的类型组合使用,用 OR 连接. 当这个类型被使用时,这个槽是一次性的,当信号发送到这个槽,槽会停止接收后续信息(broken). 在Qt 6.0被引入 |
当使用队列(queued)方式时,相关参数必须是QT可以接受的类型(types that are known to Qt’s meta-object system), 因为 Qt 要传递参数到后台的事件进程。如果你用队列方式时遇到以下错误:
QObject::connect: Cannot queue arguments of type 'MyType'
在connect()之前,先使用 qRegisterMetaType() 注册相关的数据类型.
在多线程用 信号和槽时, 查找 Signals and Slots Across Threads 的相关资料. (Queued Custom Type Example, QThread)
See also:
connect() qRegisterMetaType() Q_DECLARE_METATYPE()
原文
PySide6.QtCore.Qt.ConnectionType
This enum describes the types of connection that can be used between signals and slots. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time.
| Constant | Description |
|---|---|
| Qt.AutoConnection | (Default) If the receiver lives in the thread that emits the signal, is used. Otherwise, is used. The connection type is determined when the signal is emitted. |
| Qt.DirectConnection | The slot is invoked immediately when the signal is emitted. The slot is executed in the signalling thread. |
| Qt.QueuedConnection | The slot is invoked when control returns to the event loop of the receiver’s thread. The slot is executed in the receiver’s thread. |
| Qt.BlockingQueuedConnection | Same as , except that the signalling thread blocks until the slot returns. This connection must not be used if the receiver lives in the signalling thread, or else the application will deadlock. |
| Qt.UniqueConnection | This is a flag that can be combined with any one of the above connection types, using a bitwise OR. When is set, connect() will fail if the connection already exists (i.e. if the same signal is already connected to the same slot for the same pair of objects). This flag was introduced in Qt 4.6. |
| Qt.SingleShotConnection | This is a flag that can be combined with any one of the above connection types, using a bitwise OR. When is set, the slot is going to be called only once; the connection will be automatically broken when the signal is emitted. This flag was introduced in Qt 6.0. |
With queued connections, the parameters must be of types that are known to Qt’s meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message:
QObject::connect: Cannot queue arguments of type 'MyType'
Call qRegisterMetaType() to register the data type before you establish the connection.
When using signals and slots with multiple threads, see Signals and Slots Across Threads.
See also:
connect() qRegisterMetaType() Q_DECLARE_METATYPE()
[翻译] PySide6.QtCore.Qt.ConnectionType的更多相关文章
- 【翻译】利用Qt设计师窗体在运行时创建用户界面(Creating a user interface from a Qt Designer form at run-time)
利用Qt设计师窗体在运行时创建用户界面 我们利用Calculator窗体例子中创建的窗体(Form)来展示当一个应用(application)已经生成后,是可以在其运行时产生与例子中相同的用户界面. ...
- Qt::ConnectionType(信号与槽的传递方式)
Qt::AutoConnection 自动连接:(默认值)如果信号在接收者所依附的线程内发射,则等同于直接连接.如果发射信号的线程和接受者所依附的线程不同,则等同于队列连接. Qt::DirectCo ...
- Qt class
Help on class Qt in module PyQt5.QtCore: class Qt(sip.simplewrapper) | Method resolution order: | ...
- PySide6之初级使用
背景介绍pyside6提供了Qt6的Python侧API. 在GUI程序撰写方面, 笔者不太喜欢频繁的编译过程, 倾向于随时更改代码即时查看效果. 因此, 推荐在简单应用的情况下使用pyside6, ...
- 转:QT 的点点滴滴 错误总结
转自:http://blog.csdn.net/lbsljn/archive/2009/12/29/5099590.aspx MinGw + CodeBlock + QT4.5 类定义后面要加&quo ...
- Qt源码分析之信号和槽机制
Qt的信号和槽机制是Qt的一大特点,实际上这是和MFC中的消息映射机制相似的东西,要完成的事情也差不多,就是发送一个消息然后让其它窗口响应,当然,这里的消息是广义的说法,简单点说就是如何在一个类的一个 ...
- 6、Qt Meta Object system 学习
原文地址:http://blog.csdn.net/ilvu999/article/details/8049908 使用 meta object system 继承自 QOject 类定义中添加 Q_ ...
- Qt Meta Object system 学习
原文地址:http://blog.csdn.net/ilvu999/article/details/8049908 使用 meta object system 继承自 QOject 类定义中添加 Q_ ...
- Qt对象模型之一:信号和槽
一.信号和槽机制概述 信号槽是 Qt 框架引以为豪的机制之一.所谓信号槽,实际就是观察者模式.当某个事件发生之后,比如,按钮检测到自己被点击了一下,它就会发出一个信号(signal).这种发出是没有目 ...
- Qt源码分析之信号和槽机制(QMetaObject是一个内部struct)
Qt的信号和槽机制是Qt的一大特点,实际上这是和MFC中的消息映射机制相似的东西,要完成的事情也差不多,就是发送一个消息然后让其它窗口响应,当然,这里的消息是广义的说法,简单点说就是如何在一个类的一个 ...
随机推荐
- 对于Docker和Podman的一点使用经验
前言:本文会以多个实际的线上例子,分享自己对于Docker和Podman的一点使用经验及踩过的坑,希望对读者有一点帮助. 本文bash脚本初步加工后可直接使用(兼容mac和linux系统),对于关键点 ...
- dbeaver使用详解
1.dbeaver使用本地驱动 解压 点击可执行文件 驱动管理 新建驱动 起名字 com.mysql.jdbc.Driver jdbc:mysql//{host}[:{port}]/[{databas ...
- MLOps 学习之旅「GitHub 热点速览」
又是 AI 神仙打架的一周,上周 OpenAI 发布了最新的 GPT-4o 模型,而谷歌也紧跟着开源了 Gemma 2 模型.随着 AI 大模型不断地变强,各大科技巨头正利用它们重塑自家的产品,这也让 ...
- 实战-mongodb副本集搭建以及整合springboot使用
一 mongodb介绍 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. Nosql 技术门类 redis 内存型 mongod ...
- pgsql安装与主从配置搭建
一:安装环境 查看一下安装环境:cat /etc/centos-release CentOS Linux release 7.7.1908 (Core) 二:软件下载 https://www.post ...
- C# winfrom 局域网版多人成语接龙(二)
功能基本上是完成了,要两个人完才好玩,目前 倒计时,每组游戏玩家数量这些控制变量,都是写死再代码里的,等以后想改的时候再改,这个项目核心的功能算是实现了,但还可以扩展,比如记录一下用户的游戏数据,答对 ...
- .net C# System.Text.Json 如何将 string类型的“true”转换为布尔值 解决方案
直接上解决方法的代码 先定义一个转换顺,代码如下: public sealed class AnhBoolConverter : JsonConverter<bool?> { public ...
- numpy基础--通用函数:快速的元素级数组函数
以下代码的前提:import numpy as np 通用函数(即ufunc)是一种对narray中的数组执行元素级运算的函数.可以看作简单函数(接受一个或多个标量值,并产生一个或多个标量值)的矢量化 ...
- ETL工具-nifi干货系列 第十讲 处理器RouteOnAttribute(数据流路由)
1.今天我们一起来学习下处理器RouteOnAttribute,此处理器的作用是根据属性值进行路由进而来控制数据流的走向.类似于java中的if-else或者switch-case.如下图所示. Ge ...
- Flashduty 案例分享 - 途游游戏
Flashduty 作为功能完备的事件OnCall中心,可以接入云上.云下不同监控系统,统一做告警降噪分派.认领升级.排班协同,已经得到众多先进企业的认可.我们采访了一些典型客户代表,了解他们的痛点. ...