Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [withdrawn] class without hash function compiles with VS 2010?
Forum Updated to NodeBB v4.3 + New Features

[withdrawn] class without hash function compiles with VS 2010?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 907 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I noticed that a class without qHash method overload can be used without even a compiler warning in a
    @QSet<ClassWithoutHashFunction> mySet@

    Using MinGW, I get an error an cannot compile.

    What kind of magic is VS 2010 spinning here? Or is the implementation of QHash compiler-specific?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      The Qt docs clearly say:

      [quote]QSet's value data type must be an assignable data type. You cannot, for example, store a QWidget as a value. 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.[/quote]

      Note that a pointer type should always work, regardless of what class it is pointing to. There's a generic qHash() for pointer types.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        Ooops, my mistake.

        There was a subtle difference between the .pro files used for MinGW, and the Visual Studio Solution. Hard to spot in a big project.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved