title: Access Qt ui from another class
body: <p>I am trying to make a class in Qt that will change things on my MainWindow. </p>
  
  <p>This is my code so far:</p>
  
  <p>MainWindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  
  #include "message_function.h"
  
  message_function MeFu;
  
  MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
  {
  ui-&gt;setupUi(this);
  MeFu.Print(ui);
  }
  
  MainWindow::~MainWindow()
  {
  delete ui;
  }
  </code></pre>
  
  <p>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();
  
  private:
  Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>message_function.h (My Class header)</p>
  
  <pre><code> #ifndef MESSAGE_FUNCTION_H
   #define MESSAGE_FUNCTION_H
  
  #include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QMainWindow&gt;
  
  namespace Ui { class MainWindow; }
  
  class message_function
  {
  public:
  
  void Print(Ui::MainWindow *ui);
  };
  #endif // MESSAGE_FUNCTION_H
  </code></pre>
  
  <p>message_function.cpp (My Class .cpp)</p>
  
  <pre><code> #include "message_function.h"
  
  void message_function::Print(Ui::MainWindow *ui)
  {
  ui-&gt;label-&gt;setText("This is a test");
  }
  </code></pre>
  
  <p>When i buld my project i get this error:</p>
  
  <p>mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall message_function::Print(class Ui::MainWindow *)" (?Print@message_function@@QAEXPAVMainWindow@Ui@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)</p>
  
  <p>I don't know if i am doing this correctly or if i am doing something wrong.
  Can somebody help me get this to work?</p>