title: (Qt) Read access error when attempting to use any function from another widget class on my MainWindow
body: <p>I'd like to access some functions of a dialog-type widget from my <code>mainwindow.cpp</code>.</p>
  
  <p>I've created a simple function in the widget class that returns an int, which looks like this:</p>
  
  <p>dialog.h:</p>
  
  <pre><code> public:  
        int getRowCountData();
  </code></pre>
  
  <p>dialog.cpp:</p>
  
  <pre><code> int Dialog::getRowCountData()
   {
        return ui-&gt;tableWidget-&gt;rowCount();
   }
  </code></pre>
  
  <p>Usage: </p>
  
  <p>my mainWindow.h:</p>
  
  <pre><code>private:
      Dialog *dialog;
  </code></pre>
  
  <p>my mainwindow.cpp: </p>
  
  <pre><code>dialog = new Dialog;
  
  
  int count = dialog-&gt;getRowCountData();   &lt;&lt;&lt;&lt;&lt;--------------this throws a read access error!
  </code></pre>
  
  <p><em>code: 0xc0000005 read access violation at: 0x0 flas=0x0</em></p>
  
  <p>how am I to use another widget's public functions such as this simple one?  </p>
  
  <p>I must not be referencing the integer I'd like to set using the rowcount function. Signals and slots have worked great for me in the past when using them to transfer data between widgets, but I'd like to stick to using my dialog widget's function like this if I can. </p>
  
  <p>I came about this method for retrieving data on my other widget by posting <a href="https://stackoverflow.com/q/25872862/1751090">this question: AccessingQTableWidget's data from another class</a>. @Chernobyl maybe you have some further insight to provide?</p>
  
  <p>Thanks in advance!</p>