[PyQt] Problem with signal and slot arguments

Florian Bruhin me at the-compiler.org
Tue Oct 29 10:17:40 GMT 2019


Hey Sietse,

On Tue, Oct 29, 2019 at 11:08:29AM +0100, s.achterop at rug.nl wrote:
>     [...]
> 
>     @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?

The @pyqtSlot decorator takes the types of the slot arguments, so your
@pyqtSlot() decorator means "this is a slot without any arguments".

You probably want @pyqtSlot(QBluetoothDeviceInfo) instead.

Florian

-- 
https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20191029/baca93b6/attachment.sig>


More information about the PyQt mailing list