直接看代码吧。
子窗口头文件:
signals:
void sendSignal_lineEdit_returnPressed(QString, QString, QString, QString, QString, QString);
private:
Ui::AdjustPCClass ui;
private slots:
void on_lineEdit_returnPressed();
子窗口cpp:
void AdjustPC::on_lineEdit_returnPressed()
{
emit sendSignal_lineEdit_returnPressed(this->ui.lineEdit_x->text(),
this->ui.lineEdit_y->text(),
this->ui.lineEdit_z->text(),
this->ui.lineEdit_roll->text(),
this->ui.lineEdit_pitch->text(),
this->ui.lineEdit_yaw->text());
}
主窗口头文件:
private slots:
void receiveSignal_lineEdit_returnPressed(QString, QString, QString, QString, QString, QString);
private:
// Sub window Variables
AdjustPC* SubWidget_AdjustPC = new AdjustPC;
主窗口cpp:
// Sub window slots 关键地方,connect函数放在构造函数或者头文件中!!!
connect(SubWidget_AdjustPC, SIGNAL(sendSignal_lineEdit_returnPressed(QString, QString, QString, QString, QString, QString)), this, SLOT(receiveSignal_lineEdit_returnPressed(QString, QString, QString, QString, QString, QString)));
void Lidar_test::on_PushButton_AdjustPC_Clicked()
{ // Show sub window
SubWidget_AdjustPC->setWindowTitle("Adjust PointCloud Console");
SubWidget_AdjustPC->show();
}
void Lidar_test::receiveSignal_lineEdit_returnPressed(QString lineEdit_x_text, QString lineEdit_y_text, QString lineEdit_z_text, QString lineEdit_roll_text, QString lineEdit_pitch_text, QString lineEdit_yaw_text)
{
// Main window slot func
}