title: Emitting signals with custom types does not work
body: <p>I'm trying to emit signal with custom type. Type is declared with <strong>Q_DECLARE_METATYPE</strong> and registered with <strong>qRegisterMetaType</strong>.</p>
  
  <p>When I emit a signal, then I get next error to the output stream:</p>
  
  <pre><code>Type "MyType" has id:  1024 ; register status:  true
  QObject::connect: Cannot queue arguments of type 'MyType' (Make sure 'MyType' is registered using qRegisterMetaType().)
  </code></pre>
  
  <p>Bug is reproducable only if a queued connection is used (when objects are in different threads or explicit <code>Qt::QueuedConnection</code> is used) <em>and</em> <code>MyType</code> is declared inside a namespace.</p>
  
  <p>Sample code:
  MyType.h</p>
  
  <pre><code>#define SHOW_BUG
  
  #ifdef SHOW_BUG
  
      namespace NS
      {
          struct MyType
          {
              int val;
          };
      }
      Q_DECLARE_METATYPE( NS::MyType );
  
  #else
  
      struct MyType
      {
          int val;
      };
      Q_DECLARE_METATYPE( MyType );
  
  #endif
  </code></pre>
  
  <p>MyClass.h:</p>
  
  <pre><code>#include "MyType.h"
  
  namespace NS
  {
  
      class MyClass
          : public QObject
      {
          Q_OBJECT
      public:
          MyClass( QObject *parent = NULL );
          ~MyClass();
  
      signals:
          void sendMyType( const MyType&amp; tt );
  
      public slots:
          void invokeBug();
          void getMyType( const MyType&amp; tt );
      };
  
  }
  </code></pre>
  
  <p>MyClass.cpp</p>
  
  <pre><code>#include &lt;QDebug&gt;
  
  namespace NS
  {
  
      MyClass::MyClass(QObject *parent)
          : QObject(parent)
      {
          qRegisterMetaType&lt; MyType &gt;();
      }
  
      MyClass::~MyClass()
      {
      }
  
      void MyClass::invokeBug()
      {
          const int id = qMetaTypeId&lt; MyType &gt;();
          const bool test = QMetaType::isRegistered( id );
          qDebug() &lt;&lt; "Type \"MyType\" has id: " &lt;&lt; id &lt;&lt; "; register status: " &lt;&lt; test;
  
          MyType tt;
          tt.val = 42;
          emit sendMyType( tt );
      }
  
      void MyClass::getMyType( MyType const&amp; tt )
      {
          qDebug() &lt;&lt; "Slot fired: " &lt;&lt; tt.val;
      }
  
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include "MyClass.h"
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a( argc, argv );
  
      NS::MyClass c1;
      NS::MyClass c2;
      QThread thread;
      thread.start();
  
      c2.moveToThread( &amp;thread );
  
      QObject::connect( &amp;c1, &amp;NS::MyClass::sendMyType, &amp;c2, &amp;NS::MyClass::getMyType );
      QTimer::singleShot( 0, &amp;c1, SLOT( invokeBug() ) );
  
      return a.exec();
  }
  </code></pre>