qwindowscontext.cpp =============================================================================================== case QtWindows::InputMethodKeyDownEvent: { QWindowsInputContext *windowsInputContext = qobject_cast(QWindowsIntegration::instance()->inputContext()); if (windowsInputContext && !windowsInputContext->isComposing()) { if (msg.wParam == VK_HANJA) return windowsInputContext->reconvertByQt(hwnd); } } qwindowsinpucontext.cpp ================================================================================================ bool QWindowsInputContext::reconvertByQt(HWND hwnd) { // Reconversion performed by Qt. // Call this for Korean IME when wParam is VK_HANJA under WM_IME_KEYDOWN. QObject *fo = QGuiApplication::focusObject(); if (!fo) return false; if (!(ImmGetProperty(GetKeyboardLayout(0), IGP_SETCOMPSTR) & SCS_CAP_SETRECONVERTSTRING)) return false; unsigned int rcSizeWithout = reconvertString(hwnd, (LPARAM)NULL); if (rcSizeWithout <= sizeof(RECONVERTSTRING)) return false; std::vector rcStructure(rcSizeWithout, '\0'); PRECONVERTSTRING reconvert = (PRECONVERTSTRING) &rcStructure[0]; reconvert->dwSize = rcSizeWithout; unsigned int rcSizeWith = reconvertString(hwnd, reconvert); const HIMC himc = ::ImmGetContext(hwnd); if (!himc) return false; if (!::ImmSetCompositionStringW(himc, SCS_SETRECONVERTSTRING, reconvert, rcSizeWith, NULL, 0)) { ::ImmReleaseContext(hwnd, himc); return false; } ::ImmReleaseContext(hwnd, himc); return true; }