Using UWP API with Qt

c++ qt uwp

382 观看


208 作者的声誉

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?

For example:

#include <windows.devices.enumeration.h>

DeviceAccessInformation deviceInfo;

I get error: C2065: 'DeviceAccessInformation': undeclared identifier


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.

Also I have checked the samples, and add the namespace. using namespace winrt;

and it displays the error: C2871: 'winrt': a namespace with this name does not exist

Also I have noticed the warning: -1: warning: winrt_manifest_install.path is not defined: install target not created

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.

Update 2:

Can anyone confirm that Qt 5.9.3 UWP x32/x64 kits work with UWP API? Thanks in advance.

作者: Cobra91151 的来源 发布者: 2017 年 12 月 27 日

回应 1


208 作者的声誉


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.

作者: Cobra91151 发布者: 2018 年 1 月 5 日