在 Get HWND on windows with Qt5 (from WId) 的答案之一中建议使用 QPlatformNative接口(interface)为了恢复 native 窗口处理程序。
要访问 QT header ,尽管该示例使用其完整路径:
#include <QtGui/5.0.0/QtGui/qpa/qplatformnativeinterface.h>
当然,这作为最终解决方案是 Not Acceptable 。
有没有办法包含 QPlatformNative接口(interface)使用 QT 的默认包含系统?
请注意,两者都没有
#include <QPlatformNativeInterface>
有效(在默认 QT 构建期间不会生成此文件)
也不
#include <QGuiApplication>
有效(仅包含 QPlatformNativeInterface 的前向声明)
最佳答案
您可以使用
QT += gui-private
在您的项目文件中,如 example plugin ,然后就
#include <qpa/qplatformnativeinterface.h>
应该工作(至少对我有用)。
这些 API 确实是私有(private)的,但如果你必须使用它们,我想这比添加
#ifdef
更好。对于每个版本。
关于QT5 QPlatformNativeInterface 和 HWND,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15432432/