Problem with signal and slot arguments

"[email protected]" <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.