title: Can't access Qt ui from void function
body: <p>My mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
     Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
      void test();
  
  private:
  Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>My mainwindow.cpp file</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  }
  
  void MainWindow::test()
  {
      ui-&gt;textBrowser-&gt;append("Hello world");
  }
  </code></pre>
  
  <p><s>QT designer says "ui was not declared in this scope" But i am using it all in the same cpp file.</s></p>
  
  <p>Edit* Added mainwindow.h for more info.</p>