Re: Problem with signal and slot arguments
Dennis Jensen <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <[email protected]> |
Your @pyqtSlot() must reflect what you are receiving -- this pyqtSlot says the Slot is receiving no parameters while your Signal is sending parameters so they are not syncing up and the Signal is ignored I run a Discord server that is a python3-pyqt5 classroom-like tutoring/mentoring message server just shoot me a friend request on Discord (free to use software) at either `DenniO#8137` and/or `DeJoker#1460` if you would like to join in On 10/29/2019 5:08 AM, [email protected] wrote: > Hello list, > > I am porting the lowenergyscanner example from qt5/qtconnectivity to > PyQt5. > This as a first step to my own BLE app. I have a few problems with it. > > First a problem with signals and slots. > The C++ code snippets were: > > void addDevice(const QBluetoothDeviceInfo&); > > ... > > connect(discoveryAgent, > &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, > this, &Device::addDevice); > ... > > void Device::addDevice(const QBluetoothDeviceInfo &info) > { > if (info.coreConfigurations() & > QBluetoothDeviceInfo::LowEnergyCoreConfiguration) > setUpdate("Last device added: " + info.name()); > } > > Converted to PyQt5: > > self.discoveryAgent = QtBt.QBluetoothDeviceDiscoveryAgent() > self.discoveryAgent.deviceDiscovered.connect(self.addDevice) > > @pyqtSlot() > def addDevice(self, info): > if info.coreConfigurations() & > QtBt.QBluetoothDeviceInfo.LowEnergyCoreConfiguration: > self.setUpdate(f'Last device added: {info.name}') > > Running this gets me the following error: > > TypeError: addDevice() missing 1 required positional argument: 'info' > > With ipython3 this seems to be a warning, with python3 the progam > aborts immediately. > > It seems that the slot is being called without the info argument, but > signal > QBluetoothDeviceDiscoveryAgent().deviceDiscovered > does have the argument. > > What am I doing wrong here? > > Thanks in advance, > Sietse > _______________________________________________ > PyQt mailing list [email protected] > https://www.riverbankcomputing.com/mailman/listinfo/pyqt _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt