以下内容是 previous question 的后续内容.
我有一个 Qt 对话框窗口,其中包含一个 QPlainTextEdit
小部件,我为其创建了一个软件输入面板 (SIP),遵循示例 here 。在此示例中,输入小部件,例如QPlainTextEdit
,必须单击两次才能显示 SIP。这是因为(参见示例)单击 QPlainTextEdit
时不会引发 QEvent::WindowActivate
事件。
我正在考虑的解决方法是在 QPlainTextEdit
获得焦点时引发 QEvent::WindowActivate
事件。因此,我想知道是否可以引发 QEvent::WindowActivate
事件以及如何执行 - 假设解决方法有意义。
最佳答案
在 qt-project.org forum 上找到了解决方案
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(newFocus, &event);
关于c++ - 引发 QT QEvent::WindowActivate 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17432707/