title: Is it possible to mix template-derived C++ classes with Qt's Q_OBJECT?
body: <p>In my application, I have the following class hierarchy:</p>
  
  <pre><code>class Word
  {
      ...
  }
  
  template &lt;typename T&gt; class Dictionary
  {
      ...
  };
  
  class WordDictionary : public Dictionary&lt;Word&gt;
  {
      Q_OBJECT
  
      ...
  }
  </code></pre>
  
  <p>The WordDictionary class parses a dictionary which takes a long time. I am running the parsing function from within a separate thread and I want it to be able to signal the GUI thread from time to time to provide progress updates based on the current line number being parsed. That's why I want it to be a Q_OBJECT. I tried to make the base class Dictionary a Q_OBJECT but got a message that Q_OBJECT templates are not supported. When I removed the macro, leaving only WordDictionary as Q_OBJECT, I get a bunch of error messages of the general form:</p>
  
  <blockquote>
    <p>.\GeneratedFiles\Release\moc_dictionary.cpp(44) : error C2039: 'staticMetaObject' : is not a member of 'Dictionary'<br>
           with<br>
           [<br>
               T=Word<br>
           ]</p>
  </blockquote>
  
  <p>Is there anything I can do to make my template-derived WordDictionary class a Q_OBJECT other than hardcoding the template functions inside it, producing a lot of boilerplate code?</p>
  
  <p><strong>edit:</strong> Changing the template declaration to:</p>
  
  <pre><code>template &lt;typename T&gt; class Dictionary : public QObject
  </code></pre>
  
  <p>made the code compile. I'm not sure if I'm not doing something stupid and if this will work correctly, though.</p>