title: Qt - No matching function for call to ‘QVariant::QVariant(MyClass&)’
body: <p>I'm having trouble creating a <code>QVariant</code> with a custom type. Here is a small example that shows what I want to achieve:</p>
  
  <p>main.cpp:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "MyClass.h"
  
  int main() {
    MyClass some_object;
    QVariant variant(some_object);
    return 0;
  }
  </code></pre>
  
  <p>include/MyClass.h:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#pragma once
  
  #include &lt;QtCore&gt;
  
  class MyClass {
  public:
    MyClass() : _my_member(0.0) {}
  
    MyClass(const MyClass &amp;other) { _my_member = other._my_member; }
  
    ~MyClass() {}
  
    MyClass&amp; operator=(MyClass&amp; other)
    {
      swap(*this, other);
      return *this;
    }
  
    MyClass(MyClass&amp;&amp; other) : MyClass()
    {
      swap(*this, other);
    }
  
    friend void swap(MyClass&amp; first, MyClass&amp; second)
    {
      using std::swap;
      swap(first._my_member, second._my_member);
    }
  
  private:
    float _my_member;
  };
  Q_DECLARE_METATYPE(MyClass);
  </code></pre>
  
  <p>The build fails with the following error: </p>
  
  <pre><code>error: no matching function for call to ‘QVariant::QVariant(MyClass&amp;)’
    QVariant variant(some_object);
                                ^
  </code></pre>
  
  <p>How can I solve this error?</p>