C++ – MFC Control in a Qt Tab Widget

cmfcqtqt-mfc-migration

I'm working on a project that is using the Qt/MFC Migration Framework and I'm trying to reuse some existing MFC controls inside of a Qt dialog.

Does anyone know if it is possible to insert an MFC control (CDialog or CWnd) inside of a QTabWidget. Right now we're doing the opposite, we have an MFC dialog with a tab control which is populated with a mix of MFC tabs (CDialog) and Qt tabs (QWinWidget). However, this approach is giving me a headache because the QWinWidget controls are not properly being drawn nor are they receiving focus or keyboard input correctly. I am hoping that using a Qt dialog with a QTabWidget will work better than this approach.

Best Answer

Seeing as you use QWinWidget, you must have come cross QWinHost? Simply use QWinHost as the pages for a QTabWidget:

HWND w = ...;
QTabWidget * tw = new QTabWidget;
QWinHost * wh = new QWinHost;
wh->setWindow( w );
tw->addTab( tr("Page with Windows Control"), wh );
Related Topic