提高QT QEvent :: WindowActivate事件 [英] Raising a QT QEvent::WindowActivate event

查看:1768
本文介绍了提高QT QEvent :: WindowActivate事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是上一个问题

我有一个Qt对话框窗口,其中包含一个 QPlainTextEdit ,为此我创建了一个软件输入面板(SIP),下面的例子这里。在该示例中,输入小部件 QPlainTextEdit ,必须单击两次才能显示SIP。这是因为(见示例)没有引发 QEvent :: WindowActivate 事件,点击了 QPlainTextEdit

I've got a Qt dialog window that contains a QPlainTextEdit widget, for which I've created a Software Input Panel (SIP), following the example here. In this example an input widget, e.g. QPlainTextEdit, must be clicked twice in order for the SIP to appear. This is because (see example) a QEvent::WindowActivate event is not raised the QPlainTextEdit is clicked.

我考虑的解决方法是在 QPlainTextEdit时产生 QEvent :: WindowActivate 获得焦点。因此,我想知道如何可以提出 QEvent :: WindowActivate 事件以及如何做 - 假设解决方法有意义。

The workaround that I'm considering is to raise a QEvent::WindowActivate event when a QPlainTextEdit gets focus. Therefore I'd like to know how if it is possible to raise a QEvent::WindowActivate event and how to do so -- assuming the workaround makes sense.

推荐答案

找到解决方案,在qt-project.org 论坛

Found the solution, on the qt-project.org forum

QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(newFocus, &event);

这篇关于提高QT QEvent :: WindowActivate事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆