QString and some Qt classes are recognized as incomplete types
<p>My code looks like this:</p>

<p><strong>a.h</strong></p>

<pre><code>#include &lt;QString&gt;

namespace foo {
  QString bar(QString a);
}
</code></pre>

<p><strong>a.cc</strong></p>

<pre><code>#include "a.h"

namespace foo {
  QString bar(QString a) { return QString(); } 
}
</code></pre>

<p>The issue is in a.cc, <code>QString</code> might be taken as <code>foo::QString</code>, thus results in incomplete type compilation error, 'cause we didn't and never want to define a <code>QString</code> class in <code>foo</code> namespace.</p>

<p>Note that I have CMakeLists.txt containing below lines:</p>

<pre><code>set(CMAKE_AUTOMOC ON)
find_package(Qt5 COMPONENTS widgets REQUIRED)
set(Qt_LIBRARIES Qt5::Widgets)
target_link_libraries(a Qt_LIBRARIES)
</code></pre>

<p>Any idea? Thanks!</p>

<hr>

<p>Kuba Ober have pointed my problem exactly.</p>

<p>Actually I have a header file with 500 lines code. Say <strong>a.h</strong> looks like this</p>

<p><a href="https://i.stack.imgur.com/hebH0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hebH0.png" alt="a.h"></a></p>

<p>Note that the braces for foo is not closed. While due to too much lines and the compiler (VS2013) <strong><em>doesn't</em></strong> complaint it with red underscores, I just didn't detect it.</p>

<p>Then in a.cc, we have code like this<br>
<a href="https://i.stack.imgur.com/4tY51.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4tY51.png" alt="a.cc"></a></p>

<p>'Cause we include a.h in a.cc, even the <code>std</code> is wrapped under the <code>suri</code> namespace. Thus the <code>QString</code> might be wrapped under <code>suri</code> too, resulting in <code>recognized as incomplete type</code> compilation error.</p>

<p>This is the whole story. Thank you, guys!</p>