All i want to do is call a method when the value of a qspinbox and a doublespinbox are changed.
I do not need the actual value from the spinbox being changed, i just want it to trigger the calling of another method. Why does the code below not error or do anything at all? Not even call the method?
cpp
connect(uiSpinBox, SIGNAL(valueChanged()), this, SLOT(slotInputChanged));
connect(uiDoubleSpinBox, SIGNAL(valueChanged()), this, SLOT(slotInputChanged));
void ColorSwatchEdit::slotInputChanged()
{
qDebug() << "Im here";
}
header
public:
QSpinBox *uiSpinBox;
QDoubleSpinBox *uiDoubleSpinBox;
public slots:
void slotInputChanged();
Even if you do not use the data that carries the signal you must establish the signature in the connection:
connect(uiSpinBox, SIGNAL(valueChanged(int)), this, SLOT(slotInputChanged));
connect(uiDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotInputChanged));
But it is recommended that you use the new connection syntax as it would have indicated the error:
connect(uiSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &ColorSwatchEdit::slotInputChanged);
connect(uiDoubleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ColorSwatchEdit::slotInputChanged);