What is the best way to calculate the qHash
value of a QRect
? I need to use QRect
(and maybe QRectF
) as the key of QCache
. Right now I am using something like this:
inline uint qHash(const QRect & r)
{
return qHash(QByteArray::fromRawData((const char*)&r, sizeof(r)));
}
It seems to work but I don't like casting it into some raw bytes and since QRect is noy a simple struct, this may break sooner than later in future versions of Qt.
BTW. I don't store the hash values so it doesn't have to be persistent or cross-platform. But it does need to be reliable and fast.
Thanks.