Another issue with QNetworkInformation

Detlev Offenbach detlev at die-offenbachs.de
Tue Sep 7 18:48:11 BST 2021


Hi Phil,

thanks for this explanation. In that case I will go with the "working" 
solution, i.e. not use the @pyqtSlot decorator.

Thanks,
Detlev

Am 07.09.21 um 16:43 schrieb Phil Thompson:
> On 06/09/2021 16:07, Detlev Offenbach wrote:
>> Hello,
>>
>> I just upgraded to the latest PyQt6 snapshot. With this I get another
>> error message trying to connect to the
>> QNetworkInformation.reachabilityChanged signal. The message is
>>
>> ------------------------------------------------------------------------
>>
>> qt.core.qobject.connect: QObject::connect: Incompatible
>> sender/receiver arguments
>>         QNetworkInformation::reachabilityChanged(Reachability) -->
>> EricNetworkIcon::__reachabilityChanged(QNetworkInformation::Reachability) 
>>
>>
>> ------------------------------------------------------------------------
>> The slot is defined with "@pyqtSlot(QNetworkInformation.Reachability).
>> Defining the slot without @pyqtSlot works ok. What am I doing wrongly?
>
> IMHO it's a Qt bug and one that is difficult to work around.
>
> When a Qt signal has an argument that is an enum with the same scope 
> as the signal then Qt sometimes declares the enum argument with a 
> fully qualified name and sometimes just with the base name. In this 
> case it's...
>
>     void reachability(Reachability)
>
> ...but I think it should be...
>
>    void reachability(QNetworkInformation::Reachability)
>
> It doesn't matter to C++ but it does matter to moc because it uses the 
> type as specified as a string. moc doesn't use the fully qualified 
> name as it should. This means, even in C++, you have to know exactly 
> how the signal argument was declared.
>
> pyqtSlot() will always use fully qualified type names so that's what 
> is used by connect() (incorrectly in this case). I guess a possibility 
> would be to add a 'use_this_signature_with_connect' string argument to 
> pyqtSlot() but I don't like it.
>
> I think the best thing to do in such cases is just not to use pyqtSlot().
>
> Phil

-- 
Detlev Offenbach
detlev at die-offenbachs.de



More information about the PyQt mailing list