[PyQt] Problem with signal and slot arguments
    s.achterop at rug.nl 
    s.achterop at rug.nl
       
    Tue Oct 29 10:08:29 GMT 2019
    
    
  
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
    
    
More information about the PyQt
mailing list