title: Qt / Send data from mainwindow to dialog or grab a data from mainwindow?
body: <p>There are two files:
   <code>mainwindow.cpp</code> and <code>editorplain.cpp</code></p>
  
  <p><code>editorplain.cpp</code> is dialog as widget.</p>
  
  <p>Problem: Send text data to label on another dialog.</p>
  
  <p><code>mainwidnow.cpp</code></p>
  
  <p>Action on triggered from menu call a new dialog:
  <code>er</code> will return string from mainwindow.</p>
  
  <pre><code>void MainWindow::on_actionRoot_files_triggered()
  {
      QString er = ui-&gt;selected_filename-&gt;text();
  
      Editorplain editorplainwidget;
      // HERE IS WHAT I WANT SEND A DATA TO ANOTHER DIALOG `editorplain`
      editorplainwidget.exec();
  }
  </code></pre>
  
  <p>When opening dialog I want a grab data from string <code>er</code>:</p>
  
  <pre><code>Editorplain::setData(myType myData)
  {
      ui-&gt;label_2-&gt;setText(myData.textForEdit);
  }
  </code></pre>
  
  <p>Let's explain my problem. On <code>mywindow</code> I have a string <code>er</code> which returns some string as result. This <code>er</code> should send on dialog <code>editorplain</code> and set as label for example: <code>ui-&gt;label-&gt;setText(er)</code>. Label is QLabel made on <code>QDialog</code>.</p>
  
  <p><code>Mainwindow.h</code>:</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 slots:
      void on_actionOpen_triggered();
  
      void on_actionExit_triggered();
  
      void on_actionRoot_files_triggered();
  
  private:
      Ui::MainWindow *ui;
  
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p><code>editorplain.cpp</code> file:</p>
  
  <pre><code>#include "editorplain.h"
  #include "ui_editorplain.h"
  #include "mainwindow.h"
  
  Editorplain::Editorplain(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::Editorplain)
  {
      ui-&gt;setupUi(this);
  
      // SHOULD PASS ON THIS CONTRUCTOR?
  
  }
  
  Editorplain::~Editorplain()
  {
      delete ui;
  }
  
  Editorplain::setData(myType myData)
  {
      ui-&gt;label_2-&gt;setText(myData.textForEdit);
  }
  </code></pre>