diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 5efd80619c..b8c0584a62 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1258,6 +1258,18 @@ uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW \sa isEqual() */ + +/*! + \relates QHostAddress + \since 5.9 + \fn operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) + + Returns \c false if special address \a lhs is the same as host address \a rhs; + otherwise returns \c true. + + \sa isEqual() +*/ + #ifndef QT_NO_DATASTREAM /*! \relates QHostAddress diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 3898fb02a8..fdbdbfc72c 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -161,6 +161,8 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QHostAddress) inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2) { return address2 == address1; } +inline bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) +{ return rhs != lhs; } #ifndef QT_NO_DEBUG_STREAM Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QHostAddress &); diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index a715c38f32..bc3f5650ba 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -274,6 +274,7 @@ void tst_QHostAddress::specialAddresses() QVERIFY(address == QHostAddress(address)); QVERIFY(!(QHostAddress(address) != QHostAddress(address))); QVERIFY(!(QHostAddress(address) != address)); + QVERIFY(!(address != QHostAddress(address))); { QHostAddress ha;