PyQt5 用信号槽传递list, dict可变类型

简介: PyQt5 用信号槽传递list, dict可变类型

PyQt5 用信号槽传递list, dict是无法传递的,直接使用是会报错:

PyQt doesn't behave in the same way as Qt when it comes to passing container types between threads using signals.
Specifically, there is no automatic conversion [1] to the equivalent Qt types, and therefore no implicit copying. PyQt does provide a mechanism to explicitly request such conversions, though. To do that, you can define a custom signal using either QVariantList or QVariantMap:
    py_sig_send_data = pyqtSignal('QVariantList')
However, it's important to note that QVariantMap only supports string keys.
All in all, though, it's probably simpler, clearer and safer to just explictly copy mutable python types before passing them via signals across threads.


最好的方式是将list和dict进行序列化,然后在槽函数中进行反序列化

相关文章
|
2月前
|
SQL 机器学习/深度学习 算法
【python】python指南(五):静态类型注解之List
【python】python指南(五):静态类型注解之List
26 0
【python】python指南(五):静态类型注解之List
|
4月前
|
存储 Python
Python中list, tuple, dict,set的区别和使用场景
Python中list, tuple, dict,set的区别和使用场景
|
4月前
|
存储 索引 Python
Python教程:深入了解 Python 中 Dict、List、Tuple、Set 的高级用法
Python 中的 Dict(字典)、List(列表)、Tuple(元组)和 Set(集合)是常用的数据结构,它们各自有着不同的特性和用途。在本文中,我们将深入了解这些数据结构的高级用法,并提供详细的说明和代码示例。
76 2
|
3月前
|
NoSQL Java Redis
Redis09-----List类型,有序,元素可以重复,插入和删除快,查询速度一般,一般保存一些有顺序的数据,如朋友圈点赞列表,评论列表等,LPUSH user 1 2 3可以一个一个推
Redis09-----List类型,有序,元素可以重复,插入和删除快,查询速度一般,一般保存一些有顺序的数据,如朋友圈点赞列表,评论列表等,LPUSH user 1 2 3可以一个一个推
|
3月前
|
存储 语音技术 Python
语音识别,函数综合案例,黑马ATM,/t/t一个对不齐,用两个/t,数据容器入门,数据容器可以分为列表(list)、元组(tuple)、字符串(str)、集合(set)、字典(dict)
语音识别,函数综合案例,黑马ATM,/t/t一个对不齐,用两个/t,数据容器入门,数据容器可以分为列表(list)、元组(tuple)、字符串(str)、集合(set)、字典(dict)
|
4月前
|
存储 Dart
Dart中的集合类型:List(数组/列表)
Dart中的集合类型:List(数组/列表)
|
5月前
|
存储 算法 数据处理
Python中的列表(List) 类型详解与实战应用
Python中的列表(List) 类型详解与实战应用
68 0
|
5月前
|
存储 安全 Java
Python教程第3章 | 集合(List列表、Tuple元组、Dict字典、Set)
Python 列表、无序列表、字典、元组增删改查基本用法和注意事项
90 1
|
5月前
|
网络协议 API 开发者
Python 3.9 性能优化:更快的 list()、dict() 和 range() 等内置类型
Python 3.9 性能优化:更快的 list()、dict() 和 range() 等内置类型
42 1
|
5月前
|
安全 Java
面试题:Java里面的List的各种类型
面试题:Java里面的List的各种类型
40 0