This code:
MyAxis *ax;
ax = static_cast<MyAxis*>(ui->customPlot->axisRect()->addAxis(QCPAxis::atLeft));
connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)),
ax, SLOT(MyAxis::rescale(QCPRange)));
gives me this run-time error:
QObject::connect: No such slot
QCPAxis::MyAxis::rescale(QCPRange)
in plotwindow.cpp:267
Usually when I get errors like this, I add Q_OBJECT
macro to class and run qmake
to fix it, but that didn't work this time.
Here is the declaration of the class:
class MyAxis : public QCPAxis
{
Q_OBJECT
public:
void setRefAxis(QCPAxis *refAxis);
void setScale(double newScale);
public Q_SLOTS:
virtual void rescale(const QCPRange &range);
private:
double scale;
QCPAxis *ref;
};
Changing the declaration to public slots:
didn't make any difference.