Use QObject::sender()
in the slot, like in the following Example:
void MainWindow::someSetupFunction( void )
{
...
connect( _foobarButton, SIGNAL(clicked()), this, SLOT(buttonPressedSlot()) );
}
void MainWindow::buttonPressedSlot()
{
// e.g. check with member variable _foobarButton
QObject* obj = sender();
if( obj == _foobarButton )
{
...
}
// e.g. casting to the class you know its connected with
QPushButton* button = qobject_cast<QPushButton*>(sender());
if( button != NULL )
{
...
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…