Another issue with QNetworkInformation
Phil Thompson
phil at riverbankcomputing.com
Tue Sep 7 15:43:37 BST 2021
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
More information about the PyQt
mailing list