使用的平台、软件与文件
Windows 7 专业版 64bit
qt-opensource-windows-x86-mingw530-5.7.0
qwt-6.1.3.zip
qwt-6.1.3.qch
安装步骤
- 搭建好Qt环境
- 下载qwt-6.1.3.qch;下载qwt-6.1.3.zip并将其中的“qwt-6.1.3”文件夹解压至任意位置(如C:\;以下内容以此位置为例)
- 把qwt-6.1.3.qch移动到“C:\Qt\Qt5.7.0\Docs\Qt-5.7”中
- 找到并打开Qt 5.7 for Desktop (MinGW 5.3.0 32 bit)这个命令行环境(在开始菜单中可以找到)
,输入以下命令
cd C:\qwt-6.1.3 qmake qwt.pro mingw32-make mingw32-make install
- 编译、安装完成后应该出现以下文件夹
。
- 把“C:\qwt-6.1.3\lib”中的"*.dll"复制到“C:\Qt\Qt5.7.0\5.7\mingw53_32\bin”中
- 把“C:\qwt-6.1.3\lib”中的"*.a"复制到“C:\Qt\Qt5.7.0\5.7\mingw53_32\lib”中
- 把“C:\qwt-6.1.3\designer\plugins\designer”中的"*.dll"复制到“C:\Qt\Qt5.7.0\5.7\mingw53_32\plugins\designer”中
- 在“C:\Qt\Qt5.7.0\5.7\mingw53_32\include”中新建“Qwt”文件夹,把“C:\qwt-6.1.3\src”中的"*.h"复制到“C:\Qt\Qt5.7.0\5.7\mingw53_32\include\Qwt”中
测试与使用
- 新建一个工程,在main.cpp中添加以下内容
#include <QApplication> #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_plot_grid.h> #include <qwt_symbol.h> #include <qwt_legend.h> int main( int argc, char **argv ) { QApplication a( argc, argv ); QwtPlot plot; plot.setTitle( "Plot Demo" ); plot.setCanvasBackground( Qt::white ); plot.setAxisScale( QwtPlot::yLeft, 0.0, 10.0 ); plot.insertLegend( new QwtLegend() ); QwtPlotGrid *grid = new QwtPlotGrid(); grid->attach( &plot ); QwtPlotCurve *curve = new QwtPlotCurve(); curve->setTitle( "Some Points" ); curve->setPen( Qt::blue, 4 ), curve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) ); curve->setSymbol( symbol ); QPolygonF points; points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 ) << QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 ) << QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 ); curve->setSamples( points ); curve->attach( &plot ); plot.resize( 600, 400 ); plot.show(); return a.exec(); }
- 在需要使用Qwt的工程的.pro文件中添加以下内容
QWT_LIB_DIR = "C:\Qt\Qt5.7.0\5.7\mingw53_32\lib" QWT_INCLUDE_DIR = "C:\Qt\Qt5.7.0\5.7\mingw53_32\include\Qwt" LIBS += -L$${QWT_LIB_DIR} \ -lqwt \ -lqwtd INCLUDEPATH += $${QWT_INCLUDE_DIR}
- 把build configuration设置为“Release”
参考资料
- http://blog.chinaunix.net/uid-20717410-id-2939720.html
- http://blog.csdn.net/tangtao_xp/article/details/8875327
- http://www.mamicode.com/info-detail-500572.html
- http://chen84769797.blog.163.com/blog/static/111620934201321101753721/
- http://blog.hehehehehe.cn/a/10158.htm
- http://www.qtcentre.org/threads/53787-HowTo-Installation-of-Qt-5-0-1-and-Qwt-6-1-0-rc3-%28Win7-64bit%29
- qwt-6.1.3.pdf