没有成员命名 'setRawData' in 'QwtPlotCurve' - 转换 Qt 4.7 为 Qt 5.8

No member named 'setRawData' in 'QwtPlotCurve' - Convert Qt 4.7 to Qt 5.8

本文关键字:Qt 转换 in 成员 setRawData QwtPlotCurve      更新时间:2023-10-16

我需要将QT遗产代码从4.7转换为5.8 ,我在QT Creator 4.2.1 Clang 7.0(Apple)64bit中有一个汇编错误。

查看.cpp文件

#include "mpiChartCurve.h"
#include <qwt_plot_curve.h>

mpiChartCurve::mpiChartCurve(QwtPlot *chart_):
    m_chart(chart_),
    m_curve(new QwtPlotCurve())
{
}
mpiChartCurve::~mpiChartCurve()
{
    // be default qwt will delete the curve when it is destroyed
    // only delete the curve when detach is called
}
void mpiChartCurve::detach()
{
    m_curve->detach();
    // hack for now?  qwt doesn't seem to redraw properly until a curve is attached after a detachment, so attach dummy
    QVector<double> x, y;
    m_curve->setRawData(x.constData(), y.constData(), 0); // JDL convert Qt4 to Qt5  BROKE
    m_curve->attach(m_chart);
    m_curve->detach();
    delete m_curve;
    m_curve = 0;
}

void mpiChartCurve::attach()
{
    if (!m_curve)
        return;
    m_curve->setRawData(m_xData.constData(),m_yData.constData(), count()); // JDL convert Qt4 to Qt5  BROKE
    m_curve->attach(m_chart);
}

.cpp中的2个错误

../src/usercontrols/mpichartcurve.cpp:23:14:错误:in qwtplotcurve' in ofor:no成员'setRawdata' m_curve-> setRawdata(x.constdata(),y.constdata(),0);//JDL将QT4转换为QT5破裂 ~~~~~~~~ ^

../src/usercontrols/mpichartcurve.cpp:37:14:错误:in qwtplotcurve' no no note m_curve-> setRawdata(m_xdata.constdata(),m_ydata.constdata(),count());//JDL将QT4转换为QT5破裂 ~~~~~~~~ ^

2生成错误制作:*** [mpichartcurve.o]错误121:12:40:该过程"/usr/bin/make"已由代码2退出。构建/部署项目mypersonalindex时的错误(套件:桌面QT 5.8.0 clang 64bit)执行步骤时" make"

提到的QT5文档 setRawdata

QByteArray &    setRawData(const char *data, uint size)

我确实在QBYTEARRAY的DOC中注意到此评论

(过时)操作员const char *()const

我的C 技能非常有限,您是否看到可以将其从QT4转换为QT5的任何次要调整。...那么替代品是什么?

setRawdata不是qwtplotcurve的成员函数。它是QbyTearray的成员功能,仅接受2个参数。将setrawdata更改为setRawsamples,setrawsamples是qwtplotcurve的成员函数,接受您要寻找的三个参数。

固定版本

#include "mpiChartCurve.h"
#include <qwt_plot_curve.h>

mpiChartCurve::mpiChartCurve(QwtPlot *chart_):
    m_chart(chart_),
    m_curve(new QwtPlotCurve())
{
}
mpiChartCurve::~mpiChartCurve()
{
    // be default qwt will delete the curve when it is destroyed
    // only delete the curve when detach is called
}
void mpiChartCurve::detach()
{
    m_curve->detach();
    // hack for now?  qwt doesn't seem to redraw properly until a curve is attached after a detachment, so attach dummy
    QVector<double> x, y;
    m_curve->setRawSamples(x.constData(), y.constData(), 0); // JDL convert Qt4 to Qt5  BROKE
    m_curve->attach(m_chart);
    m_curve->detach();
    delete m_curve;
    m_curve = 0;
}

    void mpiChartCurve::attach()
{
    if (!m_curve)
        return;
    m_curve->setRawSamples(m_xData.constData(),m_yData.constData(), count()); // JDL convert Qt4 to Qt5  BROKE
    m_curve->attach(m_chart);
}