bool MyDialog::GetEditVal( int theItemID, double & val ){ QLineEdit * edit = qobject_cast <QLineEdit *> ID2Widget(theItemID); if (!edit) return false; val = edit->text().toDouble(); return true;}void MyDialog::InterfaceChanged( int theItemID ){ switch (theItemID) { case ID_VELOCITY: GetEditVal(theItemID, theData.velocity); break; case ID_ACCEL: GetEditVal(theItemID, theData.accel); break; ..... ..... }}
C++ (Qt)connect( w1, SIGNAL( valueChanged( int ) ), SLOT( changed() ) );connect( w2, SIGNAL( valueChanged( double ) ), SLOT( changed() ) );
C++ (Qt)void MainWindow::changed(){}
C++ (Qt)void MainWindow::changed(){ QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(sender()); qDebug() << sender()->metaObject()->className() << sb->property("value");}