Issue
I am trying to connect a signal
that emits a 2D array to a slot
that processes that list of list.
I am using @Slot(list)
in my slot
definition and SIGNAL("slot_method(QList<QList<QString>>)")
but that doesn't seem to work.
I would like to know what is proper conversion of a list of lists in Qt
terms.
Solution
In Python there are no 2D lists, there are only lists so you must use the signature list
.
Example:
from PySide2 import QtCore
class Sender(QtCore.QObject):
signal = QtCore.Signal(list)
def on_test(self):
l = [["a", "b", "c", "d"], ["A", "B", "C", "D"]]
self.signal.emit(l)
class Receiver(QtCore.QObject):
@QtCore.Slot(list)
def on_receiver(self, l):
print(l)
QtCore.QCoreApplication.quit()
if __name__ == '__main__':
import sys
app = QtCore.QCoreApplication(sys.argv)
sender = Sender()
receiver = Receiver()
sender.signal.connect(receiver.on_receiver)
QtCore.QTimer.singleShot(1000, sender.on_test)
sys.exit(app.exec_())
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.