简体   繁体   English

嵌入另一个窗口作为QWidget

[英]Embedding another Window as a QWidget

I'm currently working on a project that uses Allegro for rendering, input, etc. However I would like to add a GUI to my project using something like Qt. 我目前正在使用Allegro进行渲染,输入等的项目。但是,我想使用Qt之类的东西向我的项目添加GUI。 The problem is that Allegro does not support using a Window not created by allegro for rendering/input, it needs to create the window itself. 问题是Allegro不支持使用非Allegro创建的窗口进行渲染/输入,它需要创建窗口本身。 I was thinking of using Qt to make the UI, and then creating a window normally using allegro, and then somehow embedding the allegro window into the Qt application. 我当时在考虑使用Qt制作UI,然后通常使用allegro创建一个窗口,然后以某种方式将allegro窗口嵌入到Qt应用程序中。

Allegro provides the HWND handle to the window its using. Allegro向其使用的窗口提供HWND句柄。 Is there anyway to embed the allegro window into a Qt ui using its HWND handle? 无论如何,是否有使用其HWND手柄将Allegro窗口嵌入到Qt ui中的?

You need the QWinHost class from the Qt/MFC Migration Framework. 您需要Qt / MFC迁移框架中的QWinHost类。 The code is 3-clause BSD licensed. 该代码是3子句BSD许可。 You only need two files: qwinhost.h and qwinhost.cpp , available here . 您只需要两个文件: qwinhost.hqwinhost.cpp ,可在此处找到

It does exactly what you need, and works on both Qt 4 and 5. 它完全满足您的需求,并且可以在Qt 4和5上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM