直接看代码吧。
子窗口头文件:
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
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » 【Qt】用主窗口SLOT接收子窗口SIGNAL
发表评论 取消回复