VS2010下编译配置qwt

来源:互联网 发布:2016能看片的软件 编辑:程序博客网 时间:2024/05/01 04:35

A) 简介

1、QWT是一个基于LGPL版权协议的开源项目, 可生成各种统计图。它为具有技术专业背景的程序提供GUI组件和一组实用类,其目标是以基于2D方式的窗体部件来显示数据, 数据源以数值,数组或一组浮点数等方式提供, 输出方式可以是Curves(曲线),Slider(滚动条),Dials(圆盘),Compasses(仪表盘)等等。该工具库基于Qt开发,所以也继承了Qt的跨平台特性。

2、QWT官方网址:http://qwt.sourceforge.net/

     QWT6.1.0官方下载地址:http://sourceforge.net/projects/qwt/files/qwt/

3、安装步骤如下:

 

注意:安装文件目录不许出现空格。详细请看QWT帮助文档 install

 

B) VS2010+Qt4.8下的QWT安装方法(参考)

打开Qt命令窗口Qt4.8.4 command prompt,进入你的解压文件目录:

Cpp代码  收藏代码
  1. cd D:\qt\qwt  
  2. qmake qwt.pro  
  3. nmake  
  4. ---------------------  
  5.   
  6. cd designer  
  7. qmake designer.pro  
  8. nmake  
  9. ---------------------  
  10. cd ..  
  11. cd examples  
  12. qmake examples.pro  
  13. nmake  

 

执行完上面的命令后,qwt组件就编译完成了(实际通过VS2010打开如上项目,可以自动编译,省手动敲命令了)。

1、将D:\Qt\Qwt\lib的qwtd.dll 、qwt.dll拷贝到C:\Qt\4.8.4\bin,将qwtd.lib、qwt.lib拷贝C:\Qt\4.8.4\lib(以qt安装在C:\Qt\4.8.4目录下为例)目录下。qwtd.dll是我们在Debug模式需要设置的lib文件

2、再将D:\Qt\Qwt\designer\plugins\designer目录下的qwt_designer_plugin.dll和qwt_designer_plugin.lib拷贝到C:\Qt\4.8.4\plugins\designer目录下。

3、再将D:\Qt\Qwt\include目录下的所有文件拷贝到C:\Qt\4.8.4\include目录下。这样就完成了Qwt的编译和配置工作了。

在Designer中绘制用户界面时,就可以看到界面左侧的ToolBox工具箱中增加了“Qwt”类型的控件。我们在设计用户界面时就可以像使用其它Qt控件一样使用Qwt组件了。程序中要增加库文件qwt.lib,在编译后会自动的把包含的头文件包含到程序中。

 

为了能顺利编译项目,我们必须在项目中引入头文件和lib文件。

在VS2010下打开项目,需要在项目属性中,加入头文件和lib文件。

    All Configurations模式下在C/C++ /General/Addtional Include Directories 中加入C:\Qt\4.8.4\include\qwt

    Debug配置模式下,在Linker/input/Additional Dependencies中加入 qwtd.lib

    Release模式下:在Linker/input/Additional Dependencies中加入 qwt.lib

这样可以顺利编译,并可以出界面。

在QtCreator下打开工程文件pro需要加

LIBS += -L”C:\Qt\4.8.4\lib” -lqwtd INCLUDEPATH += C:\Qt\4.8.4\include\qwt

----------------------------------------------------------------------------------------------------

我参考此方法已经编译配置成功。

原文:http://johnhforrest.com/2010/09/installing-qwt-on-windows/

        I am writing this guide as a follow up to my Qt installation guide. Qwt is a graphics library built specifically for the Qt framework. I use it in my ReplayParser application to draw the APM chart, and it definitely saved a lot of time in that area of development. I haven’t had any problems in terms of the functionality of the library, but as many of the sourceforge users point out, the documentation is weak at best. So, I’ve decided to write a quick installation guide for those who are interested in utilizing this graphics library.

This guide assumes that you have installed the latest version of Qt using my previous guide as well as Visual Studio 2008. As always, please feel free to comment if any of the instructions are misleading or I have left anything out in the guide.

1. Download the latest build from the Qwt project page: http://sourceforge.net/projects/qwt/ (the current version is 5.2.1)

2. Unzip the file, and extract the contents to a folder of your choosing. I chose to place mine in C:\Qt\Qwt-5.2.1.

3. Update the configuration file, qwtconfig.pri. This is probably one of the most important steps, but also one of the least obvious ones. It took me several hours of digging online to figure out what exactly to edit for my particular configuration.

The main things to edit here are:

INSTALLBASE - make sure this path matches where you have placed the extracted folder (again, I chose mine to be C:\Qt\Qwt-5.2.1).

DEBUG/RELEASE CONFIG - the comment in the .pri file point out that you can’t mix the release and debug libraries, so I recommend building both. To do this, uncomment the debug_and_release and build_all fields, as well as commenting out the release field (this is done with a # symbol).

STATIC CONFIG – if you have built Qt statically as outlined in my previous guide, be sure to comment out the QwtDll option, otherwise you will have to distribute the .dll file with your application.

Those should be the only settings you need to change. I have uploaded my configuration file, qwtconfig.pri, as a reference for this step (I had to upload it as a .txt file, simply change the extension if you want to download it and use it directly).

4. Start the Visual Studio 2008 Command Prompt. Navigate to C:\Qt\Qwt-5.2.1\, and run the following command:

qmake

After a few seconds the qmake operation will complete (no prompt or notification will be given upon completion), and you can build the library with this command:

nmake

This will take some time, but afterwards the library will be completely built and ready for use.

5. In order to incorporate the Qwt library into your Visual Studio projects, a few last configuration steps need to be made. To do this, open up Visual Studio 2008 and click on Tools -> Options -> VC++ Directories.

Similar to the Qt configuration, there will be several paths to add. Starting with the Include Files, add your path equivalent to: C:\Qt\Qwt-5.2.1\src. Qwt is different in that it doesn’t create its own include folder, so we must instead path to its src folder as shown before. This same path will be used in Visual Studio’s Source Files for Intellisense detection. Lastly for the Library Files, add your path equivalent to C:\Qt\Qwt-5.2.1\lib. After doing all of these, close Visual Studio.

6. Re-open Visual Studio (the closing and then re-opening is important to refresh the IDE’s settings). If you have a project that you would like to use Qwt in, you must link the Qwt libraries to the project.

To do this, open your project up, right-click on the project name in the solution explorer, and click on Properties. This will open up a dialog box with several configuration options. Path to Configuration Properties -> Linker -> Input. In the Input tab, the top field should be called Additional Dependencies. Assuming you have already done the steps of creating a Qt project, all of the associated Qt library dependencies should be here. Simply add these dependencies to the end of the list:

qwtd.lib (for the debug mode) and

qwt.lib (for the release mode)

Be sure to only add one for each mode of your project.

7. Theoretically, that should complete the installation and configuration. However, in my experience there always seem to be a few technical issues here and there, so if this guide doesn’t work 100% for you, post a comment below and I will try and help debug what is going wrong. I highly recommend also exploring the examples that come with the Qwt download, as the online documentation can be very frustrating to go through.

Good luck!


原创粉丝点击