Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.2
-
None
-
Python 3.10.6
Description
Description:
When emitting a dictionary from a QThread using a Signal, if the dictionary keys are integers, the dictionary received in the Slot function is empty.
MRE:
Using KEY_A = 1 will cause the dictionary received by the Slot method to be empty ({}) whereas it will be as expected when KEY_A="A"
from PySide6.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget from PySide6.QtCore import QThread, Signal, Slot from time import sleep import random KEY_A = 1 KEY_A = "A" KEY_B = "B" class EmitterThread(QThread): dict_signal = Signal(dict) def run(self): while True: random_dictionary = { KEY_A: str(random.randint(1,10)), KEY_B: str(random.randint(1,10)), } self.dict_signal.emit(random_dictionary) print(f"Emitted dictionary is \{random_dictionary}") sleep(1) class Widget(QWidget): def _{_}init{_}_(self): super()._{_}init{_}_() self.label = QLabel() layout = QVBoxLayout() layout.addWidget(self.label) self.setLayout(layout) self.emitter = EmitterThread() self.emitter.dict_signal.connect(self.update_label) self.emitter.start() @Slot(dict) def update_label(self, value): print(f"Received dictionary is \{value}") self.label.setText(f"\{KEY_A}: {value[KEY_A]} \{KEY_B}: {value[KEY_B]}") app = QApplication([]) widget = Widget() widget.show() app.exec()
Attachments
Issue Links
- is duplicated by
-
PYSIDE-2637 Emitting dicts in Signals does not work with ints as keys
- Closed
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-2406 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
493063,3 | WIP: Fix emission of signals with dicts of non-string type | dev | pyside/pyside-setup | Status: NEW | -2 | 0 |