cpp
void MainWindow::AutoConnectSignals()
{
// 查找所有 QSpinBox
const auto spinBoxes = findChildren<QSpinBox*>();
for (auto *spinBox : spinBoxes)
{
connect(spinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ParameterWidget::SpinBoxValueChanged);
}
// 查找所有 QDoubleSpinBox
const auto doubleSpinBoxes = findChildren<QDoubleSpinBox*>();
for (auto *doubleSpinBox : doubleSpinBoxes)
{
connect(doubleSpinBox, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ParameterWidget::SpinBoxValueChanged);
}
// 查找所有 QLineEdit
const auto lineEdites = findChildren<QLineEdit*>();
for (auto *lineEdit : lineEdites)
{
connect(lineEdit, &QLineEdit::textChanged, this, &ParameterWidget::LineEditTextChanged);
}
}