当前位置: 首页 > news >正文

网站访问量来源企业安全文化建设方案

网站访问量来源,企业安全文化建设方案,网站定制公司选哪家,免费商城网站建站系统简介 QFluentWidgets 是一个基于 Qt 的 Fluent Designer 组件库,内置超过 150 个开箱即用的 Fluent Designer 组件,支持亮暗主题无缝切换和自定义主题色。 编译示例 以 Qt5 为例(Qt6 也支持),将 libQFluentWidgets.d…

简介
QFluentWidgets 是一个基于 Qt 的 Fluent Designer 组件库,内置超过 150 个开箱即用的 Fluent Designer 组件,支持亮暗主题无缝切换和自定义主题色。
在这里插入图片描述

编译示例
以 Qt5 为例(Qt6 也支持),将 libQFluentWidgets.dll、libFramlessHelperCore.dll和 libFramelessHelperWidgets.dll 放在 lib 文件夹中,QFluentWidgets 头文件放在 include 文件夹中,项目结构如下图所示
在这里插入图片描述

接着在终端输入指令进行编译,其中 -DCMAKE_PREFIX_PATH 用于设置本机 Qt5 SDK 的路径:

cmake -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="D:/Qt/5.15.2/mingw81_64" -G "MinGW Makefiles" .cd build
cmake --build . --config Release --target all --parallel

编译完成后可以在 build/bin 目录下看到所有生成的 exe 示例文件:

在这里插入图片描述

搭配 Fluent Designer
项目结构如下图所示:

在这里插入图片描述

其中 LoginWindow.py.ui 是使用 Fluent Designer 拖拽 PyQt-Fluent-Widgets 组件生成的 ui 文件,预览效果如下:

在这里插入图片描述

ui 代码如下,从 可以看到导入的组件来自 PyQt-Fluent-Widgets :

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Form</class><widget class="QWidget" name="Form">省略代码</widget><customwidgets><customwidget><class>LineEdit</class><extends>QLineEdit</extends><header>qfluentwidgets</header></customwidget><customwidget><class>CheckBox</class><extends>QCheckBox</extends><header>qfluentwidgets</header></customwidget><customwidget><class>PrimaryPushButton</class><extends>QPushButton</extends><header>qfluentwidgets</header></customwidget><customwidget><class>HyperlinkButton</class><extends>QPushButton</extends><header>qfluentwidgets</header></customwidget><customwidget><class>BodyLabel</class><extends>QLabel</extends><header>qfluentwidgets</header></customwidget></customwidgets><resources><include location="login.qrc"/></resources><connections/>
</ui>

将该 ui 文件拖拽到 Fluent Studio 软件的设计师界面中,点击转换按钮,即可得到 C++ 组件库使用的 ui 文件。

在这里插入图片描述

项目使用的 CMakeLists.txt 代码如下:

set(DEMO_NAME LoginDemo)
cmake_minimum_required(VERSION 3.5)
project(${DEMO_NAME} VERSION 1.0)set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)find_package(Qt5 COMPONENTS Widgets Multimedia REQUIRED)# -----------------------------------------------------------------------------
file(GLOB inc_files ${CMAKE_SOURCE_DIR}/*.h)
file(GLOB src_files ${CMAKE_SOURCE_DIR}/*.cpp)qt5_wrap_ui(UI_FILES ${CMAKE_SOURCE_DIR}/ui/LoginWindow.ui)# add resource
SET(RCC_FILES ${CMAKE_SOURCE_DIR}/login.qrc)
qt5_add_resources(RCC_SOURCES ${RCC_FILES})# 设置 dll 文件夹
link_directories(${CMAKE_SOURCE_DIR}/lib)add_executable(${DEMO_NAME} ${src_files} ${inc_files} ${UI_FILES} ${RCC_SOURCES})target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Widgets QFluentWidgets FramelessHelperCore FramelessHelperWidgets)# 设置头文件搜索路径
target_include_directories(${PROJECT_NAME}PRIVATE${CMAKE_SOURCE_DIR}/include${CMAKE_SOURCE_DIR}/include/framelesshelper/include${CMAKE_SOURCE_DIR}/include/framelesshelper/src/core${CMAKE_SOURCE_DIR}/include/framelesshelper/src/widgets${CMAKE_SOURCE_DIR}/include/framelesshelper/qmake/inc/core
)

拷贝 dll 到 bin 目录

configure_file(${CMAKE_SOURCE_DIR}/lib/libFramelessHelperCore.dll C M A K E S O U R C E D I R / b u i l d / b i n / l i b F r a m e l e s s H e l p e r C o r e . d l l C O P Y O N L Y ) c o n f i g u r e f i l e ( {CMAKE_SOURCE_DIR}/build/bin/libFramelessHelperCore.dll COPYONLY) configure_file( CMAKESOURCEDIR/build/bin/libFramelessHelperCore.dllCOPYONLY)configurefile({CMAKE_SOURCE_DIR}/lib/libFramelessHelperWidgets.dll C M A K E S O U R C E D I R / b u i l d / b i n / l i b F r a m e l e s s H e l p e r W i d g e t s . d l l C O P Y O N L Y ) c o n f i g u r e f i l e ( {CMAKE_SOURCE_DIR}/build/bin/libFramelessHelperWidgets.dll COPYONLY) configure_file( CMAKESOURCEDIR/build/bin/libFramelessHelperWidgets.dllCOPYONLY)configurefile({CMAKE_SOURCE_DIR}/lib/libQFluentWidgets.dll ${CMAKE_SOURCE_DIR}/build/bin/libQFluentWidgets.dll COPYONLY)
main.cpp 代码如下,可以看到这里通过 #include “ui_LoginWindow.h” 和 ui->setupUi(this) 来使用 Fluent 组件初始化界面:

#include "ui_LoginWindow.h"
#include <FramelessHelper/Core/FramelessManager>
#include <FramelessHelper/Widgets/FramelessWidgetsHelper>
#include <FramelessHelper/Widgets/StandardSystemButton>
#include <framelessconfig_p.h>
#include <QApplication>#include <QFluentWidgets/Common/FluentApp.h>
#include <QFluentWidgets/Common/Translator.h>
#include <QFluentWidgets/Window/FluentWindow.h>using namespace qfluentwidgets;
FRAMELESSHELPER_USE_NAMESPACE
using namespace Global;class Demo : public QWidget
{Q_OBJECT
public:Demo(QWidget *parent = nullptr) : QWidget(parent), ui(new Ui::Form), titleBar(new SplitTitleBar(this)){// 启用无边框FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar();// 设置主题色setThemeColor("#28afe9");// 初始化 UIui->setupUi(this);setWindowIcon(QIcon(":/qfluentwidgets/images/logo.png"));setWindowTitle("QFluentWidgets");resize(1000, 650);setStyleSheet("Demo{background: transparent}");titleBar->titleLabel()->setStyleSheet("QLabel{ background: transparent; font: 13px 'Segoe UI'; padding: 0 4px; color: white}");// 隐藏系统标题栏的最大化和最小化按钮setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint & ~Qt::WindowCloseButtonHint);// 设置标题栏FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);helper->setTitleBarWidget(titleBar);helper->setSystemButton(titleBar->minButton(), SystemButtonType::Minimize);helper->setSystemButton(titleBar->maxButton(), SystemButtonType::Maximize);helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close);titleBar->raise();}protected:void resizeEvent(QResizeEvent *e){QWidget::resizeEvent(e);titleBar->resize(width(), titleBar->height());}private:Ui::Form *ui;SplitTitleBar *titleBar;
};int main(int argc, char *argv[])
{// enable dpi scale
#if (QT_VERSION > QT_VERSION_CHECK(5, 14, 0))QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endifQApplication::setAttribute(Qt::AA_EnableHighDpiScaling);QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);QApplication app(argc, argv);// 启用云母效果FramelessConfig::instance()->set(Option::EnableBlurBehindWindow);FramelessConfig::instance()->set(Option::DisableLazyInitializationForMicaMaterial);// 国际化ftranslator.load(QLocale());Demo w;w.show();return app.exec();
}#include "main.moc"

编译指令不变,双击 build/bin/LoginWindow.exe 就能看到效果:

在这里插入图片描述

写在最后
C++ 组件库需要许可证才能拿到头文件和动态链接库使用,如果想体验运行效果,可以安装 Python 组件库并运行各个 demo.py,或者下载编译好的 PyQt-Fluent-Widgets-Gallery,最终效果和 C++ 是一样的。

http://www.bjxfkj.com.cn/article/110603.html

相关文章:

  • 自学编程网站网站开发需要用到的技术
  • 能够沟通业务的网站设计师自己的网站
  • 网站推广策划方案范文重庆做营销网站
  • 邹平做网站windows优化大师的特点
  • php网站建设设计制作wordpress 连接数据库
  • 做网站需要的语言网站开发工具的是什么
  • 北京建网站公司怎么样网站大全app下载
  • 宁波网站关键词ip可以用wordpress
  • 四川省建设工程质量监理协会网站百度网站备案
  • 太原北京网站建设wordpress改版权
  • 怎么搜索网站内容杭州做产地证去哪个网站
  • 男女性直接做的视频网站pdf插件 wordpress
  • wordpress农业站模板wordpress 1 s
  • 南宁网站快速排名提升深圳网站建设 制作元
  • 优化好的网站请人做彩票网站多少钱
  • 高端网站建设服务商上海雍熙wordpress手机端样式
  • 中小学网站建设探讨天津网络优化网站建设
  • 做网站售后几年珠海seo海网站建设
  • 做网站能赚能去什么公司桂林做手机网站建设
  • 网站后台的数据库怎么做美团网站是用什么做的
  • 承德网站建设价格网站首页轮播图怎么做的
  • 建立网站链接结构的基本方式有哪些百度域名的ip地址
  • 网站制作成功后怎么使用站酷网电脑版
  • 漯河哪个网站推广效果好上海那家网站做的好
  • 输变电壹级电力建设公司网站wordpress新增页面
  • 网站建设公司导航wordpress影视网站
  • 个人网页设计图片素材网新网站前期seo怎么做
  • 如何在网站添加代码4399网页游戏大全电脑版在线玩
  • 我是做网站怎么赚钱2013网站设计
  • 深圳有没有可以做家教的网站最新远程网站建设服务器