'emit' in 'pyqtSignal not find
-
Hi,
Without the code triggering the message, no.
-
@SGaist
Here is the codeimport sys
from PyQt6.QtWidgets import *
from PyQt6.QtCore import pyqtSignalclass FenetreSimple(QWidget):
simpleSignal = pyqtSignal()
signalAvance = pyqtSignal(int, list, str)def __init__(self, parent=None): super(FenetreSimple, self).__init__(parent) self.edition = None self.editionCopie = None self.fermer = None self.disposition = None self.execute() def execute(self): self.resize(250, 300) self.move(500, 200) self.edition = QLineEdit() self.disposition.addWidget(self.edition) self.editionCopie = QLineEdit() self.disposition.addWidget(self.editionCopie) self.edition.textChanged.connect(self.exempleSlot) self.setLayout(self.disposition) def boutonSlot(self, checked=False): self.simpleSignal.emit(2, [1, 2, 3], 'Hello') def slotAvance(self, *args): print("I am a simple slot") print(args[0]) print(args[2]) self.show()
if name == 'main':
application = QApplication(sys.argv)
fenetre = FenetreSimple()
sys.exit(application.exec()) -
Why are you mixing PySide6 and PyQt6 ?
-
@Yattara said in 'emit' in 'pyqtSignal not find:
simpleSignal = pyqtSignal() signalAvance = pyqtSignal(int, list, str) self.simpleSignal.emit(2, [1, 2, 3], 'Hello')
Although the error message sounds surprising, try calling the correct signal for the parameters you pass and see if it changes?
Otherwise please copy and paste the error message and confirm the line number it is on.
-
@Yattara Next time please ensure that your example really allows to reproduce your issue. Here
boutonSlot
will never be called because it's not called from anywhere. Also, yourFenetreSimple
widget is never shown.Anyway, here is a small example that works with a complex signal.
import sys from PyQt6.QtWidgets import QApplication from PyQt6.QtWidgets import QPushButton from PyQt6.QtWidgets import QHBoxLayout from PyQt6.QtWidgets import QWidget from PyQt6.QtCore import pyqtSignal class Widget(QWidget): complex_signal = pyqtSignal(int, list, str) def __init__(self, parent=None): super().__init__(parent) button = QPushButton("Test me") layout = QHBoxLayout(self) layout.addWidget(button) button.clicked.connect(self.on_clicked) self.complex_signal.connect(self.on_complex_signal) def on_clicked(self, checked=False): self.complex_signal.emit(2, [1, 2, 3], 'Hello') def on_complex_signal(self, *args): for idx, item in enumerate(args): print(idx, item) if __name__ == '__main__': application = QApplication(sys.argv) widget = Widget() widget.show() sys.exit(application.exec())