'QwtPlotLayout' 中没有命名'setMargin'的成员 - 将 Qt4.7 转换为 Qt5.8
No member named 'setMargin' in 'QwtPlotLayout' - Convert Qt4.7 to Qt5.8
我需要将QT遗产代码从4.7转换为5.8 ,我在QT Creator 4.2.1 Clang 7.0(Apple)64bit中有一个汇编错误。我正在使用最新的QWT 6.1.3
查看.cpp文件
#include "frmMainChart_UI.h"
#include <QHeaderView>
#include <qwt_plot_layout.h>
#include <qwt_legend.h>
#include "mpiDateScale.h"
#include "mpiPercentScale.h"
void frmMainChart_UI::setupUI(QWidget *parent_)
{
frmMainTableViewTree_UI::setupUI(QMap<int, QString>(), false, parent_);
delete frmMainTableViewTree_UI::tableCopy;
delete frmMainTableViewTree_UI::table;
chart = new mpiChart(widget);
chart->setAxisScaleDraw(QwtPlot::xBottom, new mpiDateScale());
chart->setAxisScaleDraw(QwtPlot::yLeft, new mpiPercentScale());
chart->plotLayout()->setCanvasMargin(20);
chart->plotLayout()->setMargin(20); // BROKE convert Qt4 to Qt5
chartZoomer = new mpiPlotZoomer(chart->canvas()); // BROKE convert Qt4 to Qt5
chartLegend = new QwtLegend(chart);
chart->insertLegend(chartLegend, QwtPlot::RightLegend);
QLinearGradient grad(0, 0, 1, 1);
grad.setCoordinateMode(QGradient::StretchToDeviceMode);
grad.setColorAt(0, Qt::white);
grad.setColorAt(1, QColor(220, 220, 220));
.cpp中的2个错误
../src/ui/frmmainchart_ui.cpp:18:26:错误:'qwtplotlayout'in'qwtplotlayout' no note 图表 -> plotlayout() -> setMargin(20);//将QT4转换为QT5
将../src/ui/frmmainchart_ui.cpp:19:23:错误:没有用于初始化'mpiplotzoomer'的匹配构造函数 ChartZoomer =新的mpiplotzoomer(Chart-> Canvas());//将QT4转换为QT5
将 ^
5个警告和2个错误生成制作:*** [frmmainchart_ui.o]错误106:58:25:"/usr/bin/make"的过程被代码2退出。构建/部署项目mypersonalindex时的错误(套件:桌面QT 5.8.0 clang 64bit)执行步骤时"制作"06:58:25:过去的时间:00:01。
QWT 6.1.3 DOCS 具有成员函数http://qwt.sourceforge.net/class_qwt_qwt_plot_layout.html
void setCanvasMargin (int margin, int axis=-1)
但没有使用成员功能
setMargin
我的C 技能非常有限,您是否看到可以将其从QT4转换为QT5的任何次要调整。...那么替代品是什么?
查看mpichart.h可能与canvas()错误
有关#ifndef MPICHART_H
#define MPICHART_H
#include "qwt_plot.h"
class mpiChart : public QwtPlot
{
Q_OBJECT
public:
mpiChart(QWidget *parent_ = 0):
QwtPlot(parent_)
{}
public slots:
void exportChart();
};
#endif // MPICHART_H
并在mpiplotzoomer.h中查看与canvas()错误
有关#ifndef MPIPLOTZOOMER_H
#define MPIPLOTZOOMER_H
#include <qwt_plot_zoomer.h>
#include <qwt_plot_canvas.h> // JDL convert Qt4 to Qt5
#include <qwt_compat.h> // JDL convert Qt4 to Qt5
class mpiPlotZoomer: public QwtPlotZoomer
{
public:
mpiPlotZoomer(QwtPlotCanvas *canvas_):
QwtPlotZoomer(canvas_, false)
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText(const QwtDoublePoint &pos_) const;
};
#endif // MPIPLOTZOOMER_H
,由于您使用的QT 4.7和QWT 1.6.3在使用5.8的QWT版本之间删除了setMargin
函数,因此您别无选择:
- 如果适合您的需求,请替换
setMargin
setCanvasMargin
调用 - 或删除
setMargin
调用
尝试两者,然后在显示GUI时看起来最好。
对于canvas()
错误,很难不看到mpiChart
和mpiPlotZoomer
声明。但是,我会尝试一下:
canvas()
过去返回QwtPlotCanvas*
。对于QWT的最新版本,它返回QWidget*
。因此,如果您的mpiPlotZoomer
构造函数期望QwtPlotCanvas*
作为参数,则必须:
-
QWidget*
替换QwtPlotCanvas*
的mpiPlotZoomer
参数类型。如果编写mpiPlotZoomer
类的人实际上不使用和QwtPlotCanvas
成员/属性(他只能将其用于育儿目的)
)
- 或用
mpiPlotZoomer( qobject_cast<QwtPlotCanvas*>( chart->canvas() ) );
替换mpiPlotZoomer(chart->canvas());
,它可以正常工作。
- 将 CMakeLists QT4 更新为 QT5
- 禁用 Qt5 代码中的旧(Qt4 样式)信号槽语法
- QT4 > QT5 for uri.queryItems();
- 'QwtPlotLayout' 中没有命名'setMargin'的成员 - 将 Qt4.7 转换为 Qt5.8
- 从Qt4移植到Qt5时丢失Ctrl+U组合键
- 通过IPC连接Qt4和Qt5进程的最佳方法是什么?
- (LINUX)从Qt4移植到QT5未定义的符号:_Zn9Qwidget11stylechangeER6QStyle
- 在Qt4的端口之后,嵌入Win32 HWND的Qt5 QWidget::create()不再工作
- Qt4 到 Qt5 链接错误
- VS2013的Qt4到Qt5迁移链接器警告(和错误)
- Qt5驱动的应用程序使用Qt4库并失败.如何避免这种情况
- 从Qt4.x(Ubuntu Linux)迁移到Qt5.1(Windows 7)
- Qt5比qt4慢,用于在TabWidget中绘制许多像素图
- Qt5到Qt4 UI文件兼容性
- 使Qt5连接式工作在Qt4中
- 从Qt5.3回到Qt4.8,有Q_DECLARE_METATYPE问题
- 即使安装了qt5,也强制使用qt4进行编译
- 由于访问键和快捷键冲突,Qt4和Qt5之间的更改
- 从QT4转换到QT5导致编译错误;c2666
- 从Qt4到Qt5的串口