qlineedit强制系统键盘为英文输入法

#ifdef WIN32
#include 
#endif
#
ifdef WIN32
	HKL hCurKL = NULL;
#endif
//强制英文输入法
hCurKL = GetKeyboardLayout(0);
LoadKeyboardLayout((LPCWSTR)QString("0x0409").utf16(), KLF_ACTIVATE);

ActivateKeyboardLayout(hCurKL, 0); //还原输入法


//关闭键盘
HWND hWnd = ::FindWindow(L"IPTip_Main_Window", NULL);
if (hWnd)
{
	::PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); //关闭键盘
}

你可能感兴趣的:(qt,c-c++)