您现在的位置是:首页 >学无止境 >Win10系统下VS2019编译Qt的Ribbon控件 -- SARibbon网站首页学无止境
Win10系统下VS2019编译Qt的Ribbon控件 -- SARibbon
简介Win10系统下VS2019编译Qt的Ribbon控件 -- SARibbon
原文链接:https://blog.csdn.net/m0_51204289/article/details/126431338
一、源码下载
【1】https://gitee.com/czyt1988/SARibbon/tree/master/src
【2】Qt下的Ribbon控件——SARibbon
二、源码编译
1、修改SARibbonBar文件夹下的CMakelists.txt文件,修改后的CMakelists.txt文件如下所示:
set(LIB_NAME SARibbonBar)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
qt5_add_resources(QRCS resource.qrc)
SET(HEADER_FILES
SAFramelessHelper.h
SARibbonStyleOption.h
SARibbonActionsManager.h
SARibbonBar.h
SARibbonCustomizeData.h
SARibbonCustomizeDialog.h
SARibbonCustomizeWidget.h
SARibbonMainWindow.h
SAWindowButtonGroup.h
SARibbonApplicationButton.h
SARibbonTabBar.h
SARibbonCategory.h
SARibbonContextCategory.h
SARibbonPannel.h
SARibbonToolButton.h
SARibbonMenu.h
SARibbonGlobal.h
SARibbonPannelOptionButton.h
SARibbonSeparatorWidget.h
SARibbonCategoryLayout.h
SARibbonGallery.h
SARibbonControlButton.h
SARibbonGalleryGroup.h
SARibbonGalleryItem.h
SARibbonComboBox.h
SARibbonElementCreateDelegate.h
SARibbonElementManager.h
SARibbonDrawHelper.h
SARibbonLineEdit.h
SARibbonCheckBox.h
SARibbonButtonGroupWidget.h
SARibbonStackedWidget.h
SARibbonQuickAccessBar.h
SARibbonCtrlContainer.h
SARibbonPannelLayout.h
SARibbonPannelItem.h
SARibbonLineWidgetContainer.h
)
qt5_wrap_cpp(MOC_HEADER_FILES ${HEADER_FILES})
SET(SOURCE_FILES
SAFramelessHelper.cpp
SARibbonStyleOption.cpp
SARibbonActionsManager.cpp
SARibbonBar.cpp
SARibbonCustomizeData.cpp
SARibbonCustomizeDialog.cpp
SARibbonCustomizeWidget.cpp
SARibbonMainWindow.cpp
SAWindowButtonGroup.cpp
SARibbonApplicationButton.cpp
SARibbonTabBar.cpp
SARibbonCategory.cpp
SARibbonContextCategory.cpp
SARibbonPannel.cpp
SARibbonToolButton.cpp
SARibbonMenu.cpp
SARibbonPannelOptionButton.cpp
SARibbonSeparatorWidget.cpp
SARibbonCategoryLayout.cpp
SARibbonGallery.cpp
SARibbonControlButton.cpp
SARibbonGalleryGroup.cpp
SARibbonGalleryItem.cpp
SARibbonComboBox.cpp
SARibbonElementCreateDelegate.cpp
SARibbonElementManager.cpp
SARibbonDrawHelper.cpp
SARibbonLineEdit.cpp
SARibbonCheckBox.cpp
SARibbonButtonGroupWidget.cpp
SARibbonStackedWidget.cpp
SARibbonQuickAccessBar.cpp
SARibbonCtrlContainer.cpp
SARibbonPannelLayout.cpp
SARibbonPannelItem.cpp
SARibbonLineWidgetContainer.cpp
)
add_definitions(-DSA_RIBBON_BAR_MAKE_LIB)
add_library(${LIB_NAME} SHARED
${QRCS}
${MOC_HEADER_FILES}
${HEADER_FILES}
${SOURCE_FILES}
)
target_link_libraries(${LIB_NAME} Qt5::Widgets)
set_target_properties(${LIB_NAME} PROPERTIES
AUTOMOC TRUE
AUTOUIC TRUE
AUTORCC TRUE
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION}
)
target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS ${LIB_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
ARCHIVE DESTINATION lib
)
install(FILES ${HEADER_FILES} DESTINATION include)
if(WIN32)
create_win32_resource_version(
TARGET ${LIB_NAME}
FILENAME ${LIB_NAME}
EXT "dll"
DESCRIPTION "Ribbon control library for Qt"
)
endif()
2、使用Cmake编译即可。
三、封装成库
1、编译成功后点击生成,在中出现如下图所示的Debug和Release文件夹
2、新建lib文件夹将Debug文件夹中的SARibbonBard.lib和Release文件夹中的SARibbonBar.lib复制粘贴进lib文件夹。
3、新建bin文件夹将Debug文件夹中的SARibbonBard.dll和SARibbonBard.pdb以及Release文件夹中的SARibbonBar.dll复制粘贴进bin文件夹。
4、新建include文件夹将src——SARibbonBar中的内容复制粘贴进include文件夹,即可完成库的封装。
四、Qt配库
1、新建QtWidgetsApplication应用程序
2、在属性页添加相应的包含目录和库目录。
3、在链接器中输入附加依赖项
五、运行测试
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。