PDA

View Full Version : Hosting a Cwnd inside a widget



perdrix
16th September 2022, 01:00
Migrating a large application to Qt. I have a Window CDialog that I want to host inside a QWidget

How to achieve that? QWinHost doesn't seem appropriate as that seems to require subclassing and modification of a native Windows app event loop which doesn't seem useful.

No I cannot re-implement that dialog in Qt in short order - it will take months of work as it has 10 custom CWnd children not of which are in any way trivial (the smallest is around 3k of code).

thanks
David

d_stranz
16th September 2022, 17:19
You might be able to make use of the QWinWidget class that can be found in the Qt Windows Migration library (https://code.qt.io/cgit/qt-solutions/qt-solutions.git/tree/qtwinmigrate). This is not part of the standard Qt distribution, so you will probably have to build it yourself. The library was written to help in solving exactly your problem - porting from a Windows application to Qt and hosting a native Windows HWND inside of a Qt widget.

Edit: I see from posts you have made on this same question in other forums that you are already using the Qt migration library, so you are already aware of QWinWidget.