title: Qt c++ GUI call from another class
body: <p>I created a button and a textbrowser via gui drag&amp;drop.
  the ui is created in the mainwindow.cpp as well as the click-button-function. There is a main.cpp but thats irrelevant cause the program shall not start until the startbutton is clicked.</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include "myserver.h"
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::on_startButton_clicked()
  {
      MyServer mServer;
  }
  </code></pre>
  
  <p>This is all fine so far, the problem is in the myServer.cpp where I want to write something into the textBrowser via <code>ui-&gt;textBrowser-&gt;append("hello hello");</code>.  but the myServer.cpp class doesn't "know" the ui.  <code>"ui" not declared identifier</code></p>
  
  <pre><code>#include "myserver.h"
  #include "mainwindow.h"
  
  
  MyServer::MyServer(QObject *parent) :
      QObject(parent)
  {
  }
  
  void MyServer::newConnection()
  {
      server = new QTcpServer(this);
  
      connect(server,SIGNAL(newConnection()),this,SLOT(newConnection()));
  
      int ports = MainWindow::port();
      if(!server-&gt;listen(QHostAddress::Any,ports))
      {
  
      }
      else
      {
          //here is the problem
          ui-&gt;textBrowser-&gt;append("hallo hallo");
      }
  }
  </code></pre>
  
  <p>normaly i would create a new (for example)
  <code>MainWindow test;</code> and call functions via this <code>test.function();</code>
  but this does not work here?</p>