Invoke common Signal for all objects of QVector
Hello,
I have create class of QwtPlotMagnifier,
Code:
{
Q_OBJECT
public:
ZoomMagnify
(QwtPlot *plot, Qt
::KeyboardModifier key
);
private:
virtual void rescale(double factor) override;
signals:
void autoScaleDisable(bool state);
};
Then I have create objects using QVector,
Code:
QVector<ZoomMagnify*> magnifier;
connect(magnifier.at(0), &ZoomMagnify::autoScaleDisable, m_checkBox, &QCheckBox::setChecked);
connect(magnifier.at(1), &ZoomMagnify::autoScaleDisable, m_checkBox, &QCheckBox::setChecked);
Now as we see I have to write 2 connect methods for both the objects to connect autoScaleDisable, so does it is possible I can write it in single connect method ?
Thanks
Re: Invoke common Signal for all objects of QVector
You can iterate over a vector in many ways.
For example
Code:
for (ZoomMagnify *zm : magnifier) {
connect(zm, &ZoomMagnify::autoScaleDisable, m_checkBox, &QCheckBox::setChecked);
}
Cheers,
_