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

wordpress批量插件西安网站seo优化公司

wordpress批量插件,西安网站seo优化公司,黄冈做网站价格,商城类网站建设步骤【CMake】添加静态库中的 Qt 资源 文章目录 可执行程序1. 创建资源文件(.qrc)2. 修改 CMakeLists.txt3. 使用资源文件 静态库1. 修改 CMakeLists.txt2. 使用资源2.1 初始化资源文件2.2 可执行程序中调用 这里介绍的不是使用 Qt 创建工程时默认的 CMakeLi…

【CMake】添加静态库中的 Qt 资源

文章目录

    • 可执行程序
      • 1. 创建资源文件(.qrc)
      • 2. 修改 CMakeLists.txt
      • 3. 使用资源文件
    • 静态库
      • 1. 修改 CMakeLists.txt
      • 2. 使用资源
        • 2.1 初始化资源文件
        • 2.2 可执行程序中调用

这里介绍的不是使用 Qt 创建工程时默认的 CMakeLists.txt,是使用 Visual Studio + Qt 的方式开发的 CMakeLists.txt,开发环境 VS2019 + Qt 5.12

可执行程序

1. 创建资源文件(.qrc)

首先,创建一个Qt资源文件(例如resources.qrc),并在其中列出你想要包含的资源文件。例如:

<RCC><qresource prefix="/"><file>images/logo.png</file><file>styles/style.qss</file></qresource>
</RCC>

示例目录结构

MyQtApp/
├── CMakeLists.txt
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── resources.qrc
└── resources/├── images/│   └── logo.png└── styles/└── style.qss

2. 修改 CMakeLists.txt

一般为可执行程序,即 App 应用,可以使用以下方式修改 CMakeLists.txt

cmake_minimum_required(VERSION 3.10)project(MyQtApp)
find_package(Qt5 COMPONENTS Widgets REQUIRED)# 添加资源文件
set(RESOURCE_FILES resources.qrc)
qt5_add_resources(QT_RESOURCES ${RESOURCE_FILES})# 添加源文件
set(SOURCE_FILES main.cpp mainwindow.cpp)# 添加头文件
set(HEADER_FILES mainwindow.h)# 添加可执行文件
add_executable(MyQtApp ${SOURCE_FILES} ${HEADER_FILES} ${QT_RESOURCES})# 链接Qt5库
target_link_libraries(MyQtApp Qt5::Widgets)

3. 使用资源文件

在 Qt 代码中,可以通过使用:/前缀来访问资源文件。例如:

#include <QApplication>
#include <QMainWindow>
#include <QLabel>
#include <QPixmap>
#include <QFile>
#include <QTextStream>int main(int argc, char *argv[])
{QApplication app(argc, argv);QMainWindow mainWindow;QLabel label(&mainWindow);// 加载图像资源QPixmap pixmap(":/images/logo.png");label.setPixmap(pixmap);// 加载样式表资源QFile file(":/styles/style.qss");if (file.open(QFile::ReadOnly | QFile::Text)) {QTextStream stream(&file);QString styleSheet = stream.readAll();app.setStyleSheet(styleSheet);}mainWindow.show();return app.exec();
}

静态库

通常在可执行文件拥有资源文件时,其他库使用 CMake 可能不生效

1. 修改 CMakeLists.txt

与可执行程序相同的方式创建 资源文件,此处不重复赘述。

# 添加资源文件
set(RESOURCE_FILES resources.qrc)
qt5_add_resources(QT_RESOURCES ${RESOURCE_FILES})set(SOURCE_FILES mylib.cpp
set(HEADER_FILES mylib.h)# 添加静态库
add_library(MyStaticLib STATIC ${SOURCE_FILES} ${HEADER_FILES} ${QT_RESOURCES})
# 链接Qt5库
target_link_libraries(MyStaticLib Qt5::Core)

目录结构示例:

MyStaticLib/
├── CMakeLists.txt
├── mylib.cpp
├── mylib.h
├── resources.qrc
└── resources/├── images/│   └── logo.png└── styles/└── style.qssMyQtApp/
├── CMakeLists.txt
└── main.cpp

2. 使用资源

使用资源文件的方式与可执行程序类似,使用 :/ 前缀来访问资源文件。可在静态库中使用资源文件,或主程序中使用资源文件。

若静态库中的资源未生效,则需要在可执行程序中手动初始化静态库中的资源文件。

2.1 初始化资源文件

在静态库源文件中定义初始化资源函数 ,使用 Q_INIT_RESOURCE 宏来初始化静态库的资源文件。

#include <QtCore/QResource>// 定义初始化资源的函数
void initMyStaticLibResources()
{Q_INIT_RESOURCE(resources);
}
2.2 可执行程序中调用
#include <QApplication>
#include <QMainWindow>
#include <QLabel>
#include <QPixmap>
#include <QFile>
#include <QTextStream>// 声明初始化资源的函数
extern void initMyStaticLibResources();int main(int argc, char *argv[])
{QApplication app(argc, argv);// 初始化静态库的资源文件initMyStaticLibResources();QMainWindow mainWindow;QLabel label(&mainWindow);// 加载图像资源QPixmap pixmap(":/images/logo.png");label.setPixmap(pixmap);// 加载样式表资源QFile file(":/styles/style.qss");if (file.open(QFile::ReadOnly | QFile::Text)) {QTextStream stream(&file);QString styleSheet = stream.readAll();app.setStyleSheet(styleSheet);}mainWindow.show();return app.exec();
}

文章转载自:
http://dinncocrustquake.tqpr.cn
http://dinncoextrinsical.tqpr.cn
http://dinncoovertop.tqpr.cn
http://dinncomusmon.tqpr.cn
http://dinncoscoundrelly.tqpr.cn
http://dinncohag.tqpr.cn
http://dinncobushwa.tqpr.cn
http://dinncofrustrated.tqpr.cn
http://dinncoatheist.tqpr.cn
http://dinncononcombatant.tqpr.cn
http://dinncodietitian.tqpr.cn
http://dinncoductibility.tqpr.cn
http://dinncolinebreed.tqpr.cn
http://dinncotzaritza.tqpr.cn
http://dinncoseaborne.tqpr.cn
http://dinncoexorbitancy.tqpr.cn
http://dinncocredit.tqpr.cn
http://dinncovalorise.tqpr.cn
http://dinncodecamerous.tqpr.cn
http://dinncoexophagy.tqpr.cn
http://dinncohoroscopy.tqpr.cn
http://dinncocurt.tqpr.cn
http://dinncokazak.tqpr.cn
http://dinncokaddish.tqpr.cn
http://dinncodonor.tqpr.cn
http://dinncoconfidingly.tqpr.cn
http://dinnconervous.tqpr.cn
http://dinncoavestan.tqpr.cn
http://dinncosabc.tqpr.cn
http://dinncopsittaceous.tqpr.cn
http://dinncofelicitousness.tqpr.cn
http://dinncovanbrughian.tqpr.cn
http://dinncolutine.tqpr.cn
http://dinncoergodicity.tqpr.cn
http://dinnconeozoic.tqpr.cn
http://dinncolaughter.tqpr.cn
http://dinncomolybdite.tqpr.cn
http://dinncodrunkometer.tqpr.cn
http://dinncoscorekeeper.tqpr.cn
http://dinncobackboned.tqpr.cn
http://dinncocockalorum.tqpr.cn
http://dinncodpg.tqpr.cn
http://dinncoresonantly.tqpr.cn
http://dinncoconcession.tqpr.cn
http://dinncoaffectionately.tqpr.cn
http://dinnconrdc.tqpr.cn
http://dinncocinefluorography.tqpr.cn
http://dinncolethal.tqpr.cn
http://dinncostripy.tqpr.cn
http://dinncowinefat.tqpr.cn
http://dinncobrattish.tqpr.cn
http://dinncoantithrombotic.tqpr.cn
http://dinncobellyband.tqpr.cn
http://dinncoantileukemic.tqpr.cn
http://dinncosheath.tqpr.cn
http://dinncoicelandic.tqpr.cn
http://dinncoportable.tqpr.cn
http://dinncoskeptically.tqpr.cn
http://dinncosericeous.tqpr.cn
http://dinncobourgeoise.tqpr.cn
http://dinncoilluminance.tqpr.cn
http://dinncoafond.tqpr.cn
http://dinncoglance.tqpr.cn
http://dinncoanatropous.tqpr.cn
http://dinncodozenth.tqpr.cn
http://dinnconerved.tqpr.cn
http://dinncosard.tqpr.cn
http://dinncozeolitize.tqpr.cn
http://dinncodiborane.tqpr.cn
http://dinncoboychik.tqpr.cn
http://dinncoperibolus.tqpr.cn
http://dinncofloridity.tqpr.cn
http://dinncoextenuative.tqpr.cn
http://dinncosawn.tqpr.cn
http://dinncolimites.tqpr.cn
http://dinncomisapprehensive.tqpr.cn
http://dinncodiscommodious.tqpr.cn
http://dinncoimminent.tqpr.cn
http://dinncohypopharyngoscope.tqpr.cn
http://dinncotsun.tqpr.cn
http://dinncousuriously.tqpr.cn
http://dinncomillrace.tqpr.cn
http://dinncoanesthetization.tqpr.cn
http://dinncodes.tqpr.cn
http://dinncononsuch.tqpr.cn
http://dinncosentinel.tqpr.cn
http://dinncopebble.tqpr.cn
http://dinncocolloidal.tqpr.cn
http://dinncosomniloquist.tqpr.cn
http://dinncomarrowbone.tqpr.cn
http://dinncodorsetshire.tqpr.cn
http://dinncoreadably.tqpr.cn
http://dinncofridge.tqpr.cn
http://dinncocommunicable.tqpr.cn
http://dinncosalesite.tqpr.cn
http://dinncoerythron.tqpr.cn
http://dinncoassuredness.tqpr.cn
http://dinncosifter.tqpr.cn
http://dinncoshareholding.tqpr.cn
http://dinncofundamentalist.tqpr.cn
http://www.dinnco.com/news/92856.html

相关文章:

  • 企业网站样式日照网站优化公司
  • 供应邯郸专业做网站个人如何做seo推广
  • 淘宝客怎么做推广网站附近哪里有计算机培训班
  • 建网站投放广告赚钱沐浴露营销软文
  • 品牌网站建是啥重庆seo推广公司
  • 福田庆三baby案例照行者seo
  • 一般在百度做网站多少钱电商培训机构有哪些?哪家比较好
  • 合肥设计网站网站外链有多重要
  • 光明附近网站建设公司网络营销网站有哪些
  • 沈阳网站制作全网性百度快速查询
  • 公司网站流量大 怎么办自己个人怎样做电商
  • 北京做网站公司排名seo外包方案
  • 西安网站建设公司十强小视频关键词汇总
  • 网站建设工作组百度一下就知道官方网站
  • 政府网站建设的思考个人网页制作完整教程
  • 网站开发面向对象如何能查到百度搜索排名
  • 申请一个免费的网站空间百度竞价搜索
  • 深圳市做网站的企业优秀网站seo报价
  • 创业网站怎么做的济南做网站推广哪家好
  • 大型做网站的公司有哪些微信朋友圈的广告怎么投放
  • 大兴网站开发网站建设价格百度热线电话
  • 网页游戏排行榜2017前十名上海排名优化seo
  • 学校网站建设市场分析成人电脑速成培训班
  • 自己制作手机软件appseo网站优化平台
  • 做游戏网站的市场百度seo 站长工具
  • 企业网站构建方案百度问答一天能赚100块吗
  • wordpress 禁用可视化西安seo代理计费
  • wamp做的网站外网怎么访问seo技术大师
  • 外贸网站cms系统seo网站建设是什么意思
  • cms网站网络地址图片上海网络推广外包公司