title: How to access elements from UI in Qt indirectly?
body: <p>I have created 3 classes in Qt: <code>MainController</code>, <code>ViewController</code> and <code>MainWindow</code>.</p>
  
  <p><code>MainWindow</code> contains getters to allow <code>ViewController</code> to update the UI. The <code>MainController</code> can only access the UI elements with help of <code>ViewController</code>. In order to connect the signals in the <code>ViewController</code> to the slots in <code>MainController</code>, I need to access the UI elements in <code>MainWindow</code> from <code>MainController</code>. How can I do this?</p>
  
  <p><code>MainController</code>:</p>
  
  <pre><code>connect(m_viewController-&gt;mainWindow_getStartListeningPushButton(), &amp;QPushButton::clicked, this, &amp;MainController::startOnlineMode);   
  </code></pre>
  
  <p><code>ViewController</code>:</p>
  
  <pre><code>QPushButton* ViewController::startDialog_getStartListeningPushButton()
  {
      return m_mainWindow-&gt;getStartListeningPushButton();
  }
  </code></pre>
  
  <p><code>MainWindow</code>:</p>
  
  <pre><code>QPushButton* MainWindow::getStartListeningPushButton()
  {
      return ui.startListeningPushButton;
  }
  </code></pre>
  
  <p>When I try to build this I get errors. I think it has to do with the pointers, but I don't know how to solve this...</p>
  
  <p><a href="https://i.stack.imgur.com/hjpxc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hjpxc.png" alt="enter image description here"></a></p>