PDA

View Full Version : QSet of QDateTime



Cucumber
20th January 2012, 23:15
Is it possible to make QSet of QDateTime in general? Cause I've got following:

no matching function for call to 'qHash(const QDateTime&)'
Thanks in advance!

ChrisW67
21st January 2012, 02:03
Not without extra effort, for the reason stated in the error message. From the QSet docs:

QSet's value data type must be an assignable data type. You cannot, for example, store a QWidget as a value; instead, store a QWidget *. In addition, the type must provide operator==(), and there must also be a global qHash() function that returns a hash value for an argument of the key's type. See the QHash documentation for a list of types supported by qHash().
QDateTime already has an operator==() but you will have to provide a qHash(const QDateTime &datetime) function. See the QHash docs for an example of how to do this.

Cucumber
21st January 2012, 02:17
Thank you for such prompt and comprehensive answer!
So I will stick with using QSet<QString> and get QString with QDateTime::toString method.