0

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:

.h
#include <windows.devices.enumeration.h>

.cpp
DeviceAccessInformation deviceInfo;

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

Update:

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
  • 610
  • 4
  • 14
  • #include , Where have you seen this type of import used? – eyllanesc Dec 27 '17 at 16:24
  • @eyllanesc It's just a test. So how to include it right? Thanks. – Cobra91151 Dec 27 '17 at 16:41
  • I'm not an expert on windows, but that include does not meet the standard of import of C ++. – eyllanesc Dec 27 '17 at 16:44
  • @eyllanesc Yes, I agree but it found the header file. When adding the `using namespace Windows::Devices::Enumeration;` it throws error: `C2039: 'Devices': is not a member of 'Windows'`. `UWP API` reference contains only namespaces. – Cobra91151 Dec 27 '17 at 16:52
  • You need Qt built for UWP. https://doc.qt.io/qt-5/supported-platforms-and-configurations.html – Alexander V Dec 27 '17 at 20:57
  • @AlexanderVX I have the Qt UWP kits installed and I can create empty `UWP` app. So I think the problem is with the wrong includes. – Cobra91151 Dec 27 '17 at 21:08
  • The problem is then likely with symbols needed to allow blocks of #ifdefs in those headers. As long as Visual Studio builds same project (?) there must be a local change enabling the symbol e.g. #define SYMBOL or /DSYMBOL. – Alexander V Dec 27 '17 at 22:07
  • @AlexanderVX Ok. I will check it. Thanks. – Cobra91151 Dec 27 '17 at 22:53

1 Answers1

0

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
  • 610
  • 4
  • 14