'setAutoTickStep':不是QCustomPlot 2.00-beta的'QCPAxis'的成员

时间:2017-06-06 05:46:51

标签: qt

我正在使用Qt5.6.1和QCustomPlot 2.00-beta。我设置了一个名为“widget”的新小部件。但是当我编码时

ui->widget->xAxis->setAutoTickStep(false);

它说

  

错误:C2039:'setAutoTickStep':不是'QCPAxis'的成员

如何解决?

2 个答案:

答案 0 :(得分:1)

使用:

QSharedPointer<QCPAxisTickerFixed> fixedTicker(new QCPAxisTickerFixed);
  customPlot->xAxis->setTicker(fixedTicker);

  fixedTicker->setTickStep(1.0); // tick step shall be 1.0
  fixedTicker->setScaleStrategy(QCPAxisTickerFixed::ssNone); // and no scaling of the tickstep (like multiples or powers) is allowed

来自:http://www.qcustomplot.com/documentation/classQCPAxisTickerFixed.html#details

答案 1 :(得分:-1)

您需要创建一个QCustomPlot类型的对象,执行customPlot->addGraph(),然后访问customPlot->xAxis->QCPAxisTicker(...)之类的设置。

看起来您正在尝试访问QWidget类型的对象的成员,该对象在重写之前对自定义绘图一无所知。旧方法和新方法都不适用于QWidget的对象。您应该使用QCPAxis的新方法;也许

ui->customPlot->xAxis->ticker()->setTickCount(0);

如果你的问题是你正试图在QtCreator中创建一个情节,你可以在其中创建一个QWidget,然后右键单击它,然后做一个&#34;推广到......&#34; 。确保QCustomPlot标头首先在项目中,然后在升级时指定定义QCustomPlot的标头。当你说,&#34;将其重命名为小部件并将其远程转移到QCustomPlot&#34;时,您的意思是&#34;将其推广到&#34;?