Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.6.2
-
None
Description
The following example shows a problem when emitting dictionaries in Signals. It works perfectly when the keys of the dictionary do not contain any ints. The moment one key is of type integer, the dictionary is empty.
I’d expect this to work, or, if it cannot work, at least raise some exception.
from PySide6.QtCore import Signal, Slot, QObject from PySide6.QtWidgets import ( QApplication, QPushButton, QMainWindow, QHBoxLayout, QWidget, ) import sys class Button(QPushButton): signal = Signal(dict, name="signal") def __init__(self) -> None: super().__init__() self.clicked.connect(self.on_clicked) @Slot(name="on_clicked") def on_clicked(self): self.signal.emit({192: "bar"}) self.signal.emit({"192": "bar"}) self.signal.emit({"192": "foo", 192: "bar"}) class Receiver(QObject): @Slot(dict, name="on_clicked") def on_signal(self, data: dict) -> None: print(f"Received {data}") app = QApplication(sys.argv) window = QMainWindow() window.setCentralWidget(QWidget()) window.centralWidget().setLayout(QHBoxLayout()) button = Button() receiver = Receiver() button.signal.connect(receiver.on_signal) window.centralWidget().layout().addWidget(button) window.show() sys.exit(app.exec())
Attachments
Issue Links
- duplicates
-
PYSIDE-2406 When emitting a dictionary using a Signal, if the dictionary keys are integers, the dictionary received in the Slot function is empty.
- Reported