Q:

connect in qt using two different classes

I want to connect a signal and a slot from two different classes in which one is using the other like this example:
form.hpp
class Form : public QDialog
{
    Q_OBJECT

public:
    explicit Form();
public slots:
     void onPushButton(void);    

};

form.cpp
Form::Form() :
    QDialog(parent)
{
    ui->setupUi(this);
    connect(..., SIGNAL(clicked()),..., SLOT(onPushButton()));

}

void Form::onPushButton(void)
{
    ui->pushButton->setText(QString("clicked"));
}

mainwindow.hpp
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);

private:
    Ui::MainWindow *ui;
    Form f;
};

mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

I know it easy to solve but I don't know how to do it. What the syntax of connect in Form::Form()?
If it was the way around I would do it like that:
connect(&f, SIGNAL(clicked()),this, SLOT(onPushButton()));

A:

The connection must be made in the MainWindow constructor, but you must use a lambda method since the signal does not pass the text to it.
form.h
class Form : public QDialog
{
    Q_OBJECT

public:
    explicit Form();
public slots:
     void processingFunction(const QString & text);    

};

form.cpp
Form::Form() :
    QDialog(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

}

void Form::processingFunction(const QString & text)
{
    // some processing
}

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->pushButton, &QPushButton::clicked, [this](){
        f.processingFunction(ui->lineEdit->text());
    });
}

