如何捕捉键盘布局的变化 [英] How to catch keyboard layout change
问题描述
我有几个问题:
- 捕获键盘布局更改事件。
- 获取当前键盘
我尝试过这个: p>
I tried this first:
bool MyWindow::event(QEvent* e)
{
if (e->type() == QEvent::KeyboardLayoutChange)
qDebug() << "Keyboard Layout Changed";
return QWidget::event(e);
}
但这种类型的事件永远不会传递。此外,我不知道如何解决其他2个问题。
But this type of event is never passed. Also, I have no idea how to solve the other 2 issues.
你能告诉我任何可行的例子在最新的Qt版本或一些其他跨平台解决方案这个问题?
Could you please show me any workable example on the latest Qt version or some other cross-platform solutions of this problem?
Qt 5.0.2
Windows 7 Visual Studio 2012
Ubuntu 12.04 G ++ 4.7.0
Qt 5.0.2
Windows 7 Visual Studio 2012
Ubuntu 12.04 G++ 4.7.0
推荐答案
没有跨平台的解决方案来获取键盘语言或在Qt内更改其布局。您将需要特定于平台的解决方案:一个用于Windows,一个用于X11。在未来,你也需要Wayland,我想。
There is no cross-platform solution to get the keyboard language or to change its layout from within Qt. You'll need platform-specific solutions: one for Windows, one for X11. In the future you'd need Wayland as well, I'd presume.
这篇关于如何捕捉键盘布局的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!