title: qvariant as key in qhash
body: <p>I want to create a data structure with QVariants a keys. It looks like this:</p>
  
  <pre><code>QHash&lt;QPair&lt;QVariant, QVariant&gt;, SHAPES::Shape* &gt; _shapes;
  </code></pre>
  
  <p>Unfortunately there is "no matching function for call to ‘qHash(const QVariant&amp;)’".</p>
  
  <p>So I defined my own implementation of qHash for QVariants:</p>
  
  <pre><code>#pragma once
  
  #include &lt;QVariant&gt;
  #include &lt;QHash&gt;
  
  uint qHash( const QVariant &amp; var )
  {
      if ( !var.isValid() || var.isNull() )
          //return -1;
          Q_ASSERT(0);
  
      switch ( var.type() )
      {
          case QVariant::Int:
                  return qHash( var.toInt() );
              break;
          case QVariant::UInt:
                  return qHash( var.toUInt() );
              break;
          case QVariant::Bool:
                  return qHash( var.toUInt() );
              break;
          case QVariant::Double:
                  return qHash( var.toUInt() );
              break;
          case QVariant::LongLong:
                  return qHash( var.toLongLong() );
              break;
          case QVariant::ULongLong:
                  return qHash( var.toULongLong() );
              break;
          case QVariant::String:
                  return qHash( var.toString() );
              break;
          case QVariant::Char:
                  return qHash( var.toChar() );
              break;
          case QVariant::StringList:
                  return qHash( var.toString() );
              break;
          case QVariant::ByteArray:
                  return qHash( var.toByteArray() );
              break;
          case QVariant::Date:
          case QVariant::Time:
          case QVariant::DateTime:
          case QVariant::Url:
          case QVariant::Locale:
          case QVariant::RegExp:
                  return qHash( var.toString() );
              break;
          case QVariant::Map:
          case QVariant::List:
          case QVariant::BitArray:
          case QVariant::Size:
          case QVariant::SizeF:
          case QVariant::Rect:
          case QVariant::LineF:
          case QVariant::Line:
          case QVariant::RectF:
          case QVariant::Point:
          case QVariant::PointF:
              // not supported yet
              break;
          case QVariant::UserType:
          case QVariant::Invalid:
          default:
              return -1;
      }
  
      // could not generate a hash for the given variant
      return -1;
  }
  </code></pre>
  
  <p>But then the compiler says, that the method is defined multiple times.</p>
  
  <p>So, how to use QVariant as keys in QHash? Or: what am I doing wrong?</p>