PDA

View Full Version : Embedding native UI in a QWidget?



Thuan Seah Tan
4th December 2013, 06:36
Hi guys,

I was wondering if anyone has experiences trying to get a UI that is written using native UI framework (e.g. MFC) and embedding it in a QWidget? Or any other UI toolkit (e.g. wxWidget) to work with Qt? I am working on an app that uses Qt for the UI, and we have a plugin interface allowing users to embed custom UI in a QWidget that we provide. We don't want to restrict users to Qt framework though.

Thuan

aamer4yu
4th December 2013, 09:23
You can have ActiveX objects embedded in Qt on Windows.. but for other applications, you might have to implement some sort of window manager in my opinion.

anda_skoa
4th December 2013, 09:44
In Qt5 some platforms support that through QWindow::fromWinId(). Also called Foreign Window support.

In Qt4 this platform specific code lives in separate classes. As aamer4yu said using ActiveQt on Windows, on X11 using QX11EmbedContainer. No idea about other platforms.

Cheers,
_

d_stranz
5th December 2013, 00:57
In Qt5 some platforms support that through QWindow::fromWinId(). Also called Foreign Window support.

This is exactly the way that non-Qt windows such as OpenGL, VTK, and others are embedded into QWindow / QWidget. Displaying the foreign window is usually not as hard as getting user interaction with it (keyboard / mouse) mapped from the foreign window's event loop into Qt events. It is generally possible, but this is where you will have the most difficulty integrating user-implemented plugins into a Qt app.

Thuan Seah Tan
5th December 2013, 02:37
This is exactly the way that non-Qt windows such as OpenGL, VTK, and others are embedded into QWindow / QWidget. Displaying the foreign window is usually not as hard as getting user interaction with it (keyboard / mouse) mapped from the foreign window's event loop into Qt events. It is generally possible, but this is where you will have the most difficulty integrating user-implemented plugins into a Qt app.

Yes, the interaction is the bit I am not sure about. The processing of events, does my native UI (e.g. CSliderCtrl which derives from CWnd) still get the event as it was parented to a native Window? Or do I have to do something to make that happen? I understand I can get a CWnd from the WId of a QWidget and use that as the parent for my MFC native widget.

anda_skoa
5th December 2013, 10:09
If the foreign window belongs to another process then I think it will just do its event processing as usual, just being visually contained in the host.

Cheers,
_