其他分享
首页 > 其他分享> > Qt——获取发送信号的对象,(如果有多个同类对象,调用一个槽函数,想知道是哪个对象调用的槽函数从而做出操作)

Qt——获取发送信号的对象,(如果有多个同类对象,调用一个槽函数,想知道是哪个对象调用的槽函数从而做出操作)

作者:互联网

1、效果

 

 

 

 

2、部分参考代码

//轴向间隙
    connect(ui.lineEdit_axi_first_x, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_first_y, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_first_z, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_reference_x, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_reference_y, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_reference_z, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_inner_radius, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
    connect(ui.lineEdit_axi_outer_radius, SIGNAL(editingFinished()), this, SLOT(_All_JianXi_LineEdit_slot()));
}

void DuoJi_GridFenHua::_All_JianXi_LineEdit_slot()// 所有的间隙网格 输入框槽函数
{
    qDebug() << QString::fromLocal8Bit("输入框编辑完成! ");
    QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());
    qDebug() << QString::fromLocal8Bit("当前输入框对象是: ")<<lineEdit->objectName();
    qDebug() << QString::fromLocal8Bit("输入框的内容是: ") << lineEdit->text();
    
}

 

标签:slot,SLOT,调用,函数,对象,JianXi,editingFinished,LineEdit,connect
来源: https://www.cnblogs.com/RedWetPlace/p/16426531.html