Add qHash(QSizePolicy)
Size policies can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtWidgets][QSizePolicy] Added qHash(QSizePolicy). Change-Id: Id219f47ac6cb236efdd73cad7b892c8efd034d5c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
d0f64542c8
commit
e593891b15
@ -331,6 +331,15 @@ void QSizePolicy::setControlType(ControlType type)
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn uint qHash(QSizePolicy key, uint seed = 0)
|
||||
\since 5.6
|
||||
\relates QSizePolicy
|
||||
|
||||
Returns the hash value for \a key, using
|
||||
\a seed to seed the calculation.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QSizePolicy::horizontalStretch() const
|
||||
|
||||
|
@ -40,6 +40,9 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QVariant;
|
||||
class QSizePolicy;
|
||||
|
||||
Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) Q_DECL_NOTHROW;
|
||||
|
||||
class Q_WIDGETS_EXPORT QSizePolicy
|
||||
{
|
||||
@ -112,6 +115,9 @@ public:
|
||||
|
||||
bool operator==(const QSizePolicy& s) const { return data == s.data; }
|
||||
bool operator!=(const QSizePolicy& s) const { return data != s.data; }
|
||||
|
||||
friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); }
|
||||
|
||||
operator QVariant() const;
|
||||
|
||||
int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
|
||||
|
@ -51,6 +51,8 @@ private Q_SLOTS:
|
||||
void dataStream();
|
||||
void horizontalStretch();
|
||||
void verticalStretch();
|
||||
void qhash_data() { data(); }
|
||||
void qhash();
|
||||
private:
|
||||
void data() const;
|
||||
};
|
||||
@ -149,8 +151,6 @@ void tst_QSizePolicy::getSetCheck()
|
||||
QCOMPARE(sp.expandingDirections(), ed);
|
||||
}
|
||||
|
||||
#undef FETCH_TEST_DATA
|
||||
|
||||
static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp,
|
||||
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
|
||||
Qt::Orientations orients)
|
||||
@ -314,5 +314,21 @@ void tst_QSizePolicy::verticalStretch()
|
||||
QCOMPARE(sp.verticalStretch(), 255);
|
||||
}
|
||||
|
||||
void tst_QSizePolicy::qhash()
|
||||
{
|
||||
FETCH_TEST_DATA;
|
||||
Q_UNUSED(ed);
|
||||
|
||||
QSizePolicy sp2(hp, vp, ct);
|
||||
sp2.setVerticalStretch(vst);
|
||||
sp2.setHorizontalStretch(hst);
|
||||
if (hfw) sp2.setHeightForWidth(true);
|
||||
if (wfh) sp2.setWidthForHeight(true);
|
||||
QCOMPARE(sp, sp2);
|
||||
QCOMPARE(qHash(sp), qHash(sp2));
|
||||
}
|
||||
|
||||
#undef FETCH_TEST_DATA
|
||||
|
||||
QTEST_MAIN(tst_QSizePolicy)
|
||||
#include "tst_qsizepolicy.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user