title: Connect button to a function QT c++
body: <p>I'm trying to connect a button to a function and after countless amounts of searches I couldn't find anything.</p>
  
  <p>I could use a on_button_clicked(goto slot) function but I plan on re-assigning the button to run more code, so I decided to use the connect() class but when I run the application nothing happens when I type into the text box and click the game_user_input_submit button I have created, and im not sure if it is even calling the function.</p>
  
  <p>MainWindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QString&gt;
  #include &lt;QtCore&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
  
      ui-&gt;setupUi(this);
      user_name_set = false;
      ui-&gt;game_chat_box-&gt;append("hi"); // a text edit box i created
      if(user_name_set == false)
      {
          connect(ui-&gt;game_user_input_submit, SIGNAL(clicked()), SLOT(setUsername()));
      }
  
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::setUsername()
  {
      username =  ui-&gt;game_user_input-&gt;text(); // get text from line edit i created
      user_name_set = true;
      ui-&gt;game_chat_box-&gt;append("BOT: Welcome " + username);
  }
  </code></pre>
  
  <p>MainWindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  #include &lt;QString&gt;
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      void setUsername();
      ~MainWindow();
  
  private slots:
      //void on_game_user_input_submit_clicked();
  
  private:
      bool user_name_set = false;
      QString username;
      Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>oh and I'm kinda new to programming c++ in general so if anybody does give me some usefull information I might need it to explain it to me, sorry</p>