QPlatformNativeInterface

QPlatformNativeInterface

Get HWND on windows with Qt5 (from WId)的答案之一中,建议使用QPlatformNativeInterface来恢复本机窗口处理程序。

尽管示例使用其完整路径来访问QT标头:

#include <QtGui/5.0.0/QtGui/qpa/qplatformnativeinterface.h>


当然,这不能作为确定的解决方案。
有没有一种方法可以使用默认的QT包含系统来包含QPlatformNativeInterface?

请注意,

#include <QPlatformNativeInterface>


有效(此文件不是在默认QT构建期间生成的)

也不

#include <QGuiApplication>


有效(仅包含QPlatformNativeInterface的前向声明)

最佳答案

您可以使用

QT += gui-private


在您的项目文件中,如example plugin所示,然后

#include <qpa/qplatformnativeinterface.h>


应该工作(至少对我有用)。

这些API确实是私有的,但是如果您必须使用它们,我想这比为每个版本添加#ifdef更好。

关于qt5 - QT5 QPlatformNativeInterface和HWND,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15432432/

10-10 16:44