title: How does qobject_cast work?
body: <p>I just found the following code in Qt and I'm a bit confused what's happening here.</p>
  
  <p>Especially as to what <code>reinterpret_cast&lt;T&gt;(0)</code> does?</p>
  
  <pre><code>template &lt;class T&gt;
  inline T qobject_cast(const QObject *object)
  {
      // this will cause a compilation error if T is not const
      register T ptr = static_cast&lt;T&gt;(object);
      Q_UNUSED(ptr);
  
  #if !defined(QT_NO_MEMBER_TEMPLATES) &amp;&amp; !defined(QT_NO_QOBJECT_CHECK)
      reinterpret_cast&lt;T&gt;(0)-&gt;qt_check_for_QOBJECT_macro(*reinterpret_cast&lt;T&gt;(const_cast&lt;QObject *&gt;(object)));
  #endif
      return static_cast&lt;T&gt;(const_cast&lt;QObject *&gt;(reinterpret_cast&lt;T&gt;(0)-&gt;staticMetaObject.cast(const_cast&lt;QObject *&gt;(object))));
  }
  </code></pre>
  
  <p>Anyone care to explain?</p>