1.在windows下使用Qt調用系統的軟鍵盤可以使用:
QDesktopServices::openUrl(QUrl("osk.exe", QUrl::TolerantMode));
在win7系統下可以使用,但是換到win10下則出現錯誤
ShellExecute 'osk.exe' failed (error 2).
win10下調用系統的軟鍵盤:
PVOID OldValue = nullptr;
BOOL bRet = Wow64DisableWow64FsRedirection(&OldValue);
QString csProcess = "C:\\Windows\\System32\\osk.exe";
QString params="";
ShellExecute(nullptr, L"open", (LPCWSTR)csProcess.utf16(), (LPCWSTR)params.utf16(), nullptr, SW_SHOWNORMAL);
if (bRet)
{
Wow64RevertWow64FsRedirection(OldValue);
}
親測可行。
大家也可以學習一下該博客:https://blog.csdn.net/flushhip/article/details/83008317