Using QT .qrc File with Visual Studio Proj...?
Using QT .qrc File with Visual Studio Proj...?
我有一个Visual Studio 2017项目,它是使用CMake使用QT和VTK构建的。我需要使用图像资源,并希望使用QT的.qrc资源系统。
不使用QT项目文件时,有关这方面的信息似乎很少见且复杂。我发现这个:
创建一个 .qrc 文件,其中包含要包含的资源列表
创建一个自定义构建步骤,在该文件上调用 rcc(文档(
编译生成的 cpp 源文件并将其链接到程序中。
如何在没有Qt项目的情况下在Visual Studio中使用Qt资源文件?
我现在完全搞不清楚正确的方法是什么,这还不够。
将此添加到您的 CMake 中:
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
这将自动运行moc和rcc编译器。
然后使用以下命令添加资源并链接它们
# Compiles binary resources into source code and puts the names into RESOURCES variable
qt5_add_resources(RESOURCES example.qrc)
# Adds the RESOURCES source code to your application so it will be linked
# and part of your executable
add_executable(exampleApplication main.cpp ${RESOURCES})
延伸阅读:
- https://doc.qt.io/qt-5/cmake-manual.html
- https://doc.qt.io/qt-5/cmake-command-reference.html
- https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-resources.html
- https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-binary-resources.html
- https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-big-resources.html
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何在MS Visual Studio 2019中运行QT UI
- 如何使用Visual Studio 2017在C++中为参数化对象数组使用唯一指针
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio 2019:插入多个C++风格的单行注释
- Visual Studio Code "undefined reference to `WinMain@16'"
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- Visual Studio中的函数声明和函数定义问题
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- Visual Studio mkl_link_tool.exe链接错误
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 不同的Visual Studio版本中缺少.dll
- 用Visual Studio在C++中嵌入Julia
- Visual Studio 2017循环自动向量化问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- Visual Studio在尝试读取resource.txt文件时崩溃
- Using QT .qrc File with Visual Studio Proj...?