2017-03-13 98 views
0

我需要將Qt遺留代碼從4.7轉換爲5.8,我在Qt Creator 4.2.1 Clang 7.0(Apple) 64位。在.cpp文件在'QwtPlotCurve'中沒有名爲'setRawData'的成員 - 將Qt 4.7轉換爲Qt 5.8

尋找

#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); 
} 

2中的錯誤的.c​​pp

../src/usercontrols/mpiChartCurve.cpp:23:14:錯誤:沒有成員命名'QwtPlotCurve'中的'setRawData' m_curve-> setRawData(x.constData(),y.constData(),0); // JDL轉換的Qt4到QT5 BROKE ~~~~~~~^

../src/usercontrols/mpiChartCurve.cpp:37:14:錯誤:未在 'QwtPlotCurve'名爲 'setRawData' 成員m_curve-> setRawData(m_xData.constData(),m_yData.constData(),count()); // JDL轉換的Qt4到QT5 BROKE ~~~~~~~^

2錯誤生成 化妝:*** [mpiChartCurve.o]錯誤1 21時12分40秒:進程「/ USR /斌/做出」退出,代碼爲2 錯誤,同時建立/部署項目mypersonalindex(包:臺式機的Qt 5.8.0鐺64位) 當執行步驟‘使’

的QT5文檔提到setRawData

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

我也注意到在文檔的QByteArray中此評論

(過時)運營商爲const char *()const的

我的C++技術是相當有限的,你看不到任何微小的調整,可以從Qt4的轉換這QT5 。 ...那麼替代品是什麼?

回答

0

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); 
}