【发布时间】:2017-08-03 01:22:59
【问题描述】:
我需要将 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:错误:在“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/bin/make”以代码 2 退出。 构建/部署项目 mypersonalindex 时出错(套件:Desktop Qt 5.8.0 clang 64bit) 执行步骤“Make”时
Qt5 文档提到setRawData
QByteArray & setRawData(const char *data, uint size)
我确实在 QByteArray 的文档中注意到了这条评论
(过时的)运算符 const char *() const
我的 C++ 技能非常有限,您是否看到任何可以将其从 Qt4 转换为 Qt5 的小调整。 ...那么替换是什么?
【问题讨论】:
标签: c++ qt qbytearray