Results 1 to 3 of 3

Thread: QSet of QDateTime

  1. #1
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSet of QDateTime

    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!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSet of QDateTime

    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.

  3. #3
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSet of QDateTime

    Thank you for such prompt and comprehensive answer!
    So I will stick with using QSet<QString> and get QString with QDateTime::toString method.

Similar Threads

  1. invalidate QDateTime
    By Markus_AC in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2011, 11:14
  2. Using custom class as a key (QSet)
    By daujeroti in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2011, 20:39
  3. QSet<QVariant> is supported ?
    By nikhilqt in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2010, 07:14
  4. QSet and custom class
    By been_1990 in forum Qt Programming
    Replies: 12
    Last Post: 22nd January 2010, 16:36
  5. QDateTime without Day
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2006, 11:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.