在 Qt 中使用 UWP API [英] Using UWP API with Qt
问题描述
在 Visual Studio
中,我包含了:using namespace Windows::Devices::Enumeration;
并且它可以工作.在 Qt
中添加/包含命名空间时,出现错误.任何文档如何将 UWP API
与 Qt
一起使用?
In Visual Studio
I included: using namespace Windows::Devices::Enumeration;
and it works. When adding/including namespaces in Qt
I get errors. Any documentation how to use UWP API
with Qt
?
例如:
.h
#include <windows.devices.enumeration.h>
.cpp
DeviceAccessInformation deviceInfo;
我收到错误:C2065: 'DeviceAccessInformation': undeclared identifier
更新:
我找到了一些与该问题相关的信息.所以我添加了 Win SDK
路径 (INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0"
) 到.pro
文件.还添加了#include "winrt/windows.devices.enumeration.h"
到头文件但它仍然找不到DeviceAccessInformation deviceInfo;
,抛出错误:C2065:DeviceAccessInformation:未声明的标识符
.
I have found some information related the issue. So I have added the Win SDK
path (INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0"
) to the .pro
file. Also added the #include "winrt/windows.devices.enumeration.h"
to the header file but it still can't find the DeviceAccessInformation deviceInfo;
, throws error: C2065: DeviceAccessInformation: undeclared identifier
.
我还检查了示例,并添加了命名空间.使用命名空间 winrt;
Also I have checked the samples, and add the namespace.
using namespace winrt;
并显示错误:C2871: 'winrt': a namespace with this name does not exist
我也注意到警告:-1: warning: winrt_manifest_install.path is not defined: install target not created
我已经包含了 WindowsApp
库,但问题仍然存在.
I have included the WindowsApp
library but the issue still exists.
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64" -lWindowsApp
} else {
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x86" -lWindowsApp
}
我认为问题在于错误的包含或我遗漏了什么.
I think the problem is with the wrong includes or I missing something.
更新 2:
谁能确认Qt 5.9.3 UWP x32/x64
套件与UWP API
兼容?提前致谢.
Can anyone confirm that Qt 5.9.3 UWP x32/x64
kits work with UWP API
? Thanks in advance.
推荐答案
我决定使用 Visual Studio
开发原生 UWP
应用程序,即使我通过安装解决了这个问题Qt
扩展 VS
并将 Win SDK
套件切换到 16299.
I have decided to develop native UWP
app using Visual Studio
even though I fixed the issue by installing Qt
extension for VS
and switching Win SDK
kit to 16299.
这篇关于在 Qt 中使用 UWP API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!