I'm gradually migrating application from MFC to Qt and using MFCMigrationFramework for this purpose.
Qt widget which is placed on MFC dialog doesn't handle such keys as Tab, Arrows, Enter, Esc. Issue with Tab and arrows was partially solved with this solution:
I've subclassed QWinWidget and have made next things: Constructor:
SetWindowLong(winId(), GWL_STYLE, GetWindowLong(winId(), GWL_STYLE) | WS_TABSTOP);
Overriden winEvent:
bool winEvent(MSG *msg, long *result)
{
switch(msg->message)
{
case WM_GETDLGCODE:
*result = DLGC_WANTARROWS | DLGC_WANTTAB;
return true;
}
return __super::winEvent(msg, result);
}
To copy to clipboard, switch view to plain text mode
It works except one issue: it's impossible to reach controls on parent dialog (MFC) using Tab key, focus cycles only through child Qt control (the first issue).
The second issue: Enter and Esc keys are handled only by parent MFC dialog. For instance, it's impossible to close opened popup of combobox (located on Qt widget) by pressing Enter or Esc key - dialog is closed instead (CDialog::OnOK or CDialog::OnCancel is called).
I've tried this
case WM_GETDLGCODE:
*result = DLGC_WANTARROWS | DLGC_WANTTAB | DLGC_WANTALLKEYS;
but in this case CDialog doesn't handle Esc and Enter keys anymore.
What is the right solution to handle such situation?