From d81e16005522d00ba789021f0895dd66d9972d2f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 21 Oct 2020 21:55:04 +0200 Subject: QRectF/QPointF/QSizeF: document that operator== and != are fuzzy This has been the case for a _very_ long time, and I can't believe this hasn't been documented anywhere. Change-Id: Ib157edf14e87a6f546c155496f70a760ab218cca Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Paul Wicking (cherry picked from commit cca62a7360a117880eea5821fd7403d68a1431c8) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qpoint.cpp | 16 ++++++++++++++-- src/corelib/tools/qrect.cpp | 14 +++++++++++--- src/corelib/tools/qsize.cpp | 15 ++++++++++++--- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index e98eaac4fc..2c2260642c 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -739,14 +739,26 @@ QDebug operator<<(QDebug dbg, const QPointF &p) \fn bool operator==(const QPointF &p1, const QPointF &p2) \relates QPointF - Returns \c true if \a p1 is equal to \a p2; otherwise returns \c false. + Returns \c true if \a p1 is approximately equal to \a p2; otherwise + returns \c false. + + \warning This function does not check for strict equality; instead, + it uses a fuzzy comparison to compare the points' coordinates. + + \sa qFuzzyCompare */ /*! \fn bool operator!=(const QPointF &p1, const QPointF &p2); \relates QPointF - Returns \c true if \a p1 is not equal to \a p2; otherwise returns \c false. + Returns \c true if \a p1 is sufficiently different from \a p2; + otherwise returns \c false. + + \warning This function does not check for strict inequality; instead, + it uses a fuzzy comparison to compare the points' coordinates. + + \sa qFuzzyCompare */ #ifndef QT_NO_DATASTREAM diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index c8301e2590..c353746430 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -2391,8 +2391,13 @@ QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW \fn bool operator==(const QRectF &r1, const QRectF &r2) \relates QRectF - Returns \c true if the rectangles \a r1 and \a r2 are equal, + Returns \c true if the rectangles \a r1 and \a r2 are \b approximately equal, otherwise returns \c false. + + \warning This function does not check for strict equality; instead, + it uses a fuzzy comparison to compare the rectangles' coordinates. + + \sa qFuzzyCompare */ @@ -2400,8 +2405,11 @@ QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW \fn bool operator!=(const QRectF &r1, const QRectF &r2) \relates QRectF - Returns \c true if the rectangles \a r1 and \a r2 are different, otherwise - returns \c false. + Returns \c true if the rectangles \a r1 and \a r2 are sufficiently + different, otherwise returns \c false. + + \warning This function does not check for strict inequality; instead, + it uses a fuzzy comparison to compare the rectangles' coordinates. */ /*! diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 3e97947ad2..09529fbaa9 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -733,15 +733,24 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NO \fn bool operator==(const QSizeF &s1, const QSizeF &s2) \relates QSizeF - Returns \c true if \a s1 and \a s2 are equal; otherwise returns - false. + Returns \c true if \a s1 and \a s2 are approximately equal; otherwise + returns false. + + \warning This function does not check for strict equality; instead, + it uses a fuzzy comparison to compare the sizes' extents. + + \sa qFuzzyCompare */ /*! \fn bool operator!=(const QSizeF &s1, const QSizeF &s2) \relates QSizeF - Returns \c true if \a s1 and \a s2 are different; otherwise returns \c false. + Returns \c true if \a s1 and \a s2 are sufficiently different; otherwise + returns \c false. + + \warning This function does not check for strict inequality; instead, + it uses a fuzzy comparison to compare the sizes' extents. */ /*! -- cgit v1.2.3