PDA

View Full Version : PYQT4 - Trying to pass a list to QProcess



cminogue15
23rd January 2015, 22:02
I have Form A which starts a QProcess B (matplotlib widget).
When events come into Form A, I need to pass a list of data over the the
QProcess B. I am assuming I can do this using signal/slots.

Is this possible?

Code in Form A:


# define signal to emit
PressureDataReady = QtCore.pyqtSignal()

# starts process
self.qPSCGraph = QProcess()
self.qPSCGraph.setProcessChannelMode(QProcess.Sepa rateChannels);
self.qPSCGraph.start('python', ['SmartCableGraphsPressureSensorData.py'])
self.qPSCGraph.finished.connect(self.PSCGraphFinis hed)

Method xyz(self):
self.emit(QtCore.SIGNAL("PressureDataReady(PyQt_PyObject)"), pressureList)

Code In Form B:
???? not sure what is needed to receive signal and call method


self.connect(self.qPSCGraph, QtCore.SIGNAL("PressureDataReady(PyQt_PyObject)"), ??????, 0)


any example to point out the correct directions would be appreciated.

Chris

jefftee
23rd January 2015, 23:33
To my knowledge, you cannot use Qt SIGNALS and SLOTS signals across separate processes.

A few other approaches you might consider based on your platform:


Write to the stdin of your QProcess, read from stderr/stdout of your QProcess, etc.
Use a database to insert work to do into a table from your main program and your QProcess checks for new work using a timer, etc.
Use some type of message queueing system to publish/consume messages between processes
Use the Qt DBUS stuff


Edit: A quick google found this (http://doc.qt.io/qt-5/ipc.html) page as well.

Hope that helps.