QT第三方库:Qwt的安装与使用

来源:互联网 发布:如何删除筛选后的数据 编辑:程序博客网 时间:2024/05/16 14:04

一个项目需要用到 qwt,查阅了一些资料后自己配置了一下,下面是我整理的配置和运用过程。

一、环境

  • QT 版本:QT 5.8.0(msvc2013_64)
  • QWT 版本:qwt 6.1.3

二、配置

  • 从官网下载 qwt 压缩包后将其解压到 QT 安装目录下;
    在这里 QT 的安装目录为 D:\Qt 。
  • 双击 qwt.pro 项目,使用 qt creater 直接打开 qwt.pro 项目;
  • 打开 qwt.pro 项目中 designer 目录下的 qwtbuild 目录中的 qwtbuild.pri;
  • 更改代码如下:

改前:

win32 {    # On Windows you can't mix release and debug libraries.    # The designer is built in release mode. If you like to use it    # you need a release version. For your own application development you    # might need a debug version.     # Enable debug_and_release + build_all if you want to build both.    CONFIG           += debug_and_release    CONFIG           += build_all}

改后:

win32 {    # On Windows you can't mix release and debug libraries.    # The designer is built in release mode. If you like to use it    # you need a release version. For your own application development you    # might need a debug version.     # Enable debug_and_release + build_all if you want to build both.    #CONFIG           += debug_and_release    CONFIG           += build_all}
  • 直接编译运行;
  • 编译好时会有一个弹窗,不用管它,直接取消就可以了,然后将 D:\Qt\Qwt\build-qwt-Desktop_Qt_5_8_0_MSVC2013_64bit-Debug\designer\plugins\designer 目录下的 qwt_designer_plugin.dll 文件拷贝到 D:\Qt\Qt5.8.0\5.8\msvc2013_64\plugins\designer 目录夹下;
  • 将 D:\Qt\Qwt\build-qwt-Desktop_Qt_5_8_0_MSVC2013_64bit-Debug\lib 目录下的 qwt.dll 和 qwtd.dll 文件拷贝到 D:\Qt\Qt5.8.0\5.8\msvc2013_64\bin 目录下;
  • 将 D:\Qt\Qwt\build-qwt-Desktop_Qt_5_8_0_MSVC2013_64bit-Debug\lib 目录下的 qwt.lib 和 qwtd.lib 文件拷贝到 D:\Qt\Qt5.8.0\5.8\msvc2013_64\lib 目录下;
  • 在 D:\Qt\Qt5.8.0\5.8\msvc2013_64\include 目录下新建文件夹 qwt ,将原 qwt 目录中 src 目录中的所有 .h 文件拷贝进该新建文件夹。

**注意:**qwt 控件需要右击 ui 文件,选择“用…打开”中的 Qt Designer 才能看到,直接双击 ui 文件打开看不到。
完成以上操作,qwt已经差不多配置好了,但还不能直接运用。

三、运用

新建一个项目,在项目文件(.pro)中添加一下代码:

LIBS += -LD:\Qt\Qt5.8.0\5.8\msvc2013_64\lib -lqwtdINCLUDEPATH += D:\Qt\Qt5.8.0\5.8\msvc2013_64\include\qwt

到这里 qwt 控件就可以运行了。

qwt运行例图.PNG