本文主要是介绍QWT 6.2.0编译的库及头文件 :已经打包成3rdparty/qwt,可以直接在你的工程里cmake导入外部库,直接使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
qwt 6.2.0打包好的库及其头文件
链接:https://pan.baidu.com/s/1yDFLUxxxR8sDfMKalA8fVw?pwd=o8gg
提取码:o8gg
cmake工程导入编译好的qwt 6.2.0外部库
- 新建CMake + Qt项目
# 在生成你的应用add_executable之前添加qwt外部库,你可以在你的工程中创建3rdparty文件夹,然后将上述网盘下载的qwt放置其中
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qwt/src)
set(qwt_lib_dir ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qwt/lib)
set(qwt_lib ${qwt_lib_dir}/qwt.lib)
set(qwt_designer_lib ${qwt_lib_dir}/qwt_designer_plugin.lib)
# 在你的应用程序生成的地方之后,添加链接qwt外部库
target_link_libraries(loadqwt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${qwt_lib} ${qwt_designer_lib})
我的完整cmakelists.txt
cmake_minimum_required(VERSION 3.5)project(loadqwt VERSION 0.1 LANGUAGES CXX)set(CMAKE_INCLUDE_CURRENT_DIR ON)set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)# CONFIG += qwt
# DEFINES += QT_DLL QWT_DLL
# LIBS += -L"C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\lib" -lqwtd
# LIBS += -L"C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\lib" -lqwt
# INCLUDEPATH += D:\develop\qwt\qwt-git\srcinclude_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qwt/src)
set(qwt_lib_dir ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qwt/lib)
set(qwt_lib ${qwt_lib_dir}/qwt.lib)
set(qwt_designer_lib ${qwt_lib_dir}/qwt_designer_plugin.lib)find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)set(PROJECT_SOURCESmain.cppwidget.cppwidget.hwidget.ui
)if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)qt_add_executable(loadqwtMANUAL_FINALIZATION${PROJECT_SOURCES})
# Define target properties for Android with Qt 6 as:
# set_property(TARGET loadqwt APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()if(ANDROID)add_library(loadqwt SHARED${PROJECT_SOURCES})
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")else()add_executable(loadqwt${PROJECT_SOURCES})endif()
endif()target_link_libraries(loadqwt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${qwt_lib} ${qwt_designer_lib})set_target_properties(loadqwt PROPERTIESMACOSX_BUNDLE_GUI_IDENTIFIER my.example.comMACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)if(QT_VERSION_MAJOR EQUAL 6)qt_finalize_executable(loadqwt)
endif()
可以结合我之前编译qwt的博客文章来查看,将你新建的工程ui文件用designer打开,然后拖动qwt控件上去
点击Qt Creator的运行按钮,此处一定要选择release运行,因为的库是release的链接库,当然我是debug版本也是放了的,这就要你在cmakeLists.txt里把release和debug的不同运行方式的库放对应好。
qwt的编译及打包使用就都完成了,接下来就是查阅qwt文档,将项目的二维绘图使用qwt来完成项目功能的开发了
这篇关于QWT 6.2.0编译的库及头文件 :已经打包成3rdparty/qwt,可以直接在你的工程里cmake导入外部库,直接使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!