title: Connecting a button in Qt
body: <p>Okay. So I've got simple Qt app, which has <code>lineEdit</code> and <code>pushButton</code> QObjects. Pressing the button should print the text which is in <code>lineEdit</code> to a <code>.txt</code> file. Simple. I've run this code, when function didn't take any parameters (just wrote some text to a file). Now it looks like this:</p>
  
  <p>mainwindow.h</p>
  
  <pre><code>private slots:
      static void on_some_pushButton_clicked(QString s);
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent),
      ui (new Ui::MainWindowClass)
  {
      ui-&gt;setupUi(this);
      ui-&gt;pushButton-&gt;setText("GO");
      //Connecting a GO pushButton to a func which saves your name into a .txt file
      auto s = ui-&gt;lineEdit-&gt;text();
      connect(ui-&gt;pushButton,SIGNAL(clicked()),this,SLOT(on_some_pushButton_clicked(s)));
  }
  
  void MainWindow::on_some_pushButton_clicked(QString s)
  {
      FILE *file;
      file=fopen("data.txt", "wt");
      fprintf(file, "XD\n");
      auto z=(s.toStdString()).c_str();
      fprintf(file, "%s", z);
      fclose(file);
  }
  </code></pre>
  
  <p>main.cpp (just in case)</p>
  
  <pre><code>#include "mainwindow.h"
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.setWindowTitle("Qt App");
      w.show();
      return a.exec();
  }
  </code></pre>
  
  <p>And, well, it doesn't do anything. I don't see the file being created, or anything like that. What am I doing wrong?</p>
  
  <p>P.S When I said that it works without parameters, I meant:</p>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>void MainWindow::button_clicked()
  {
      FILE *file;
      file=fopen("data2.txt", "wt");
      fprintf(file, "Works with no args");
      fclose(file);
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>connect(ui-&gt;pushButton_2,SIGNAL(clicked()),this,SLOT(button_clicked()));
  </code></pre>