链接:https://pan.baidu.com/s/1yDFLUxxxR8sDfMKalA8fVw?pwd=o8gg
提取码:o8gg
# 在生成你的应用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\src
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)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
set(PROJECT_SOURCES
main.cpp
widget.cpp
widget.h
widget.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(loadqwt
MANUAL_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 PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_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来完成项目功能的开发了