title: Using Qt Properties with custom types defined in namespaces
body: <p>I have currently a problem when using an own type as property type.</p>
  
  <p>My custom type is defined within a namespace. When I put it into the global namespace, everything works without any problems.</p>
  
  <p>Is it possible to use custom types within a namespace as property values?</p>
  
  <p>Here's a minimum example (I am using Qt5.0 and g++ 4.7.3)</p>
  
  <p>Here's the <code>test.pro</code> file:</p>
  
  <pre><code>LANGUAGE  = C++
  QT += core gui widgets
  TARGET = test
  QMAKE_CXXFLAGS += -std=c++11
  HEADERS += test.h
  SOURCES += test.cpp
  </code></pre>
  
  <p>Here's the <code>test.h</code> file:</p>
  
  <pre><code>#include &lt;QtCore&gt;
  #include &lt;QtGui&gt;
  #include &lt;QtWidgets&gt;
  
  namespace MyNamespace
  {
    struct MyValue
    {
    private:
      QString a;
      int b;
  
    public:
      MyValue(const QString &amp;a="", int b=0)
        : a(a), b(b)
      {
      }
  
      bool operator !=(const MyValue &amp;other) const
      {
        return (this-&gt;a!=other.a) || (this-&gt;b!=other.b);
      }
  
      friend QDataStream &amp;operator&lt;&lt;(QDataStream &amp;stream, const MyNamespace::MyValue &amp;value);
      friend QDataStream &amp;operator&gt;&gt;(QDataStream &amp;stream, MyNamespace::MyValue &amp;value);
      friend QDebug operator&lt;&lt;(QDebug debug, const MyNamespace::MyValue &amp;value);
    };
  
    inline QDataStream &amp;operator&lt;&lt;(QDataStream &amp;stream, const MyNamespace::MyValue &amp;value)
    {
      stream &lt;&lt; value.a;
      return stream &lt;&lt; value.b;
    }
  
    inline QDataStream &amp;operator&gt;&gt;(QDataStream &amp;stream, MyNamespace::MyValue &amp;value)
    {
      stream &gt;&gt; value.a;
      return stream &gt;&gt; value.b;
    }
  
    inline QDebug operator&lt;&lt;(QDebug debug, const MyNamespace::MyValue &amp;value)
    {
      return debug &lt;&lt; "MyValue("&lt;&lt;value.a&lt;&lt;", "&lt;&lt;value.b&lt;&lt;")";
    }
  }
  
  Q_DECLARE_METATYPE(MyNamespace::MyValue)
  
  
  namespace AnotherNamespace
  {
    typedef MyNamespace::MyValue MyValue;
  
    class MyClass : public QObject
    {
      Q_OBJECT
  
      Q_PROPERTY(MyValue value READ value WRITE setValue NOTIFY valueChanged)
  
    public:
      MyValue value()
      {
        return value_;
      }
  
    public slots:
      void setValue(const MyValue &amp;value)
      {
        if(this-&gt;value() != value)
        {
          value_ = value;
          emit valueChanged(value);
        }
      }
  
    signals:
      void valueChanged(const MyValue &amp;value);
  
    private:
      MyValue value_;
    };
  
  }
  </code></pre>
  
  <p>And here's the test.cpp file:</p>
  
  <pre><code>#include "test.h"
  
  int main(int argc, char** argv)
  {
    QApplication app(argc, argv);
  
    qRegisterMetaTypeStreamOperators&lt;MyNamespace::MyValue&gt;("MyNamespace::MyValue");
  
  
    AnotherNamespace::MyClass myObject;
  
    myObject.setValue(MyNamespace::MyValue("the answer", 42));
  
    QMetaObject metaObject = AnotherNamespace::MyClass::staticMetaObject;
    QMetaProperty metaProperty = metaObject.property(metaObject.indexOfProperty("value"));
    QVariant variant = metaProperty.read(&amp;myObject);
  
    MyNamespace::MyValue value = variant.value&lt;MyNamespace::MyValue&gt;();
  
    qDebug() &lt;&lt; value;
  
  
    qDebug() &lt;&lt; "\nIt's interesting, that this is working without problems:";
    variant = QVariant::fromValue(MyNamespace::MyValue("2^4", 16));
    value = variant.value&lt;MyNamespace::MyValue&gt;();
  
    qDebug() &lt;&lt; value;
  
  
    return 0;
  }
  </code></pre>
  
  <p>The output of this minimum example is</p>
  
  <pre><code>QMetaProperty::read: Unable to handle unregistered datatype 'MyValue' for property 'AnotherNamespace::MyClass::value'
  MyValue( "" ,  0 ) 
  
  It's interesting, that this is working without problems: 
  MyValue( "2^4" ,  16 ) 
  </code></pre>
  
  <p>As alreaday said, after removing any namespace usage from the minimum example, everything works without any problems with the following output</p>
  
  <pre><code>MyValue( "the answer" ,  42 ) 
  
  It's interesting, that this is working without problems: 
  MyValue( "2^4" ,  16 ) 
  </code></pre>