From d24cceebf2bad8e1172cf992644263cba2098501 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Feb 2014 15:15:01 +0100 Subject: QFont: add missing qHash overload The properties that make up the hash value are chosen to be the same as those that make up QFontDef's op<() and op==(). Indeed, the implementation for QFont simply delegates to the one of QFontDef, which has been added for this purpose, but may prove useful in its own right down the line. The code would greatly benefit from a qHash(qreal) implementation. Lacking this, the patch uses multiplication with 10000 and qRound64() to convert the one floating-point property used in the hash to an integer. This is probably the right thing to do anyway, to avoid epsilon problems. [ChangeLog][QtGui][QFont] Added qHash overload for this class. [ChangeLog][QtCore][QHash] Allowed QFont to be used as a key in QHash/QSet. Change-Id: I2c1cb5d9da53e26cb2c0f1a7c357731e73eea78e Reviewed-by: Thiago Macieira --- src/gui/text/qfont.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/text/qfont.h') diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 6d36f7839b..a207a1d60e 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -315,6 +315,8 @@ private: Q_DECLARE_SHARED(QFont) +Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) Q_DECL_NOTHROW; + inline bool QFont::bold() const { return weight() > Normal; } -- cgit v1.2.3