このコード:
MyAxis *ax;
ax = static_cast<MyAxis*>(ui->customPlot->axisRect()->addAxis(QCPAxis::atLeft));
connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)),
ax, SLOT(MyAxis::rescale(QCPRange)));
この実行時エラーが表示されます:
QObject::connect:
QCPAxis::MyAxis::rescale(QCPRange)
plotwindow.cpp:267 にそのようなスロットはありません
通常、このようなエラーが発生した場合は、Q_OBJECT
クラスにマクロを追加して実行qmake
して修正しますが、今回はうまくいきませんでした。
クラスの宣言は次のとおりです。
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;
};
宣言を変更しpublic slots:
ても違いはありませんでした。