title: how to get HWND for QDialog in Windows 10
body: <p>I'm trying to read the HWND of a dialog I sub-classed from QDialog, but I (think I) am running into a <code>Memory Access Error</code> which causes a null pointer to be returned to the client code. </p>
  
  <p>Header file - I've given up trying to get an HWND as I can't even get a WId...</p>
  
  <pre><code>#ifndef DIALOG_H
  #define DIALOG_H
  
  #include &lt;QDialog&gt;
  #include &lt;QGraphicsScene&gt;
  #include &lt;QGraphicsView&gt;
  #include &lt;QGraphicsItem&gt;
  
  namespace Ui {
  class Dialog;
  }
  
  class Dialog : public QDialog
  {
      Q_OBJECT
  
  public:
      explicit Dialog(QWidget *parent = 0);
      ~Dialog();
  
      WId getWindowHandle (void);
  private:
      Ui::Dialog *ui;
      QGraphicsScene *scene;
      QGraphicsTextItem *text;
  };
  
  #endif // DIALOG_H
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>WId Dialog::getWindowHandle() {
      WId id = this-&gt;effectiveWinId(); // debugger says id = 0
      return id;
  }
  </code></pre>
  
  <p>I've also tried this:</p>
  
  <pre><code>WId Dialog::getWindowHandle() {
      QWidget *parent = this-&gt;nativeParentWidget(); // debugger says parent = 0
      WId id = parent-&gt;effectiveWinId(); // so this crashes
      return id;
  }
  </code></pre>
  
  <p>I'm new to Qt. Hopefully there's something obvious I'm missing. </p>
  
  <p>What is the canonical way of getting a QDialog's WId?</p>
  
  <p>Toolchain: Windows 10 Anniversary, Qt 5.7, both 64 bit, Visual Studio 14 C++ compiler, Windows SDK Debugger.</p>