title: How to call to non-static parent function from within child function in Qt/C++?
body: <p>I have difficulties in understanding how to pass parent object to child. 
  In Qt, I have a MainWindow class and a <code>DoSomething()</code> function. Then I created a Job object within MainWindow and tried to call DoSomething within Job's <code>DoItNow()</code> function. But I just don't know how to do it.</p>
  
  <p>MainWindow.h</p>
  
  <pre><code>class Job;
  class MainWindow : public QMainWindow
  {
    Q_OBJECT
  
    public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
  
      int value;
      void DoSomething();
  
    private:
    Job *job;
  }
  </code></pre>
  
  <p>MainWindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "job.h"
  
  MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
  ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      job = new Job(this);   // passing this pointer to child
  }
  
  void MainWindow::DoSomething() {  // do something }
  </code></pre>
  
  <p>Job.h</p>
  
  <pre><code>class Job : public QObject
  {
    Q_OBJECT
  
    private:
      void DoItNow();
  
    public:
      explicit CDMcommand(QObject *parent = 0);
  }
  </code></pre>
  
  <p>Job.cpp</p>
  
  <pre><code>#include "job.h"
  #include "mainwindow.h"
  
  Job::Job(QObject *parent) : QObject(parent)
  {
    // some setups
    parent-&gt;value = 0;    // this is not working
  }
  
  void Job::DoItNow()
  {
    parent-&gt;DoSomething();  // What is the pointer to MainWindow instance?
  }
  </code></pre>
  
  <ul>
  <li><p>How to access non-static public register in *parent?</p></li>
  <li><p>How to pass *parent to function in job instance?</p></li>
  </ul>