繁体   English   中英

如何为QTextEdit禁用Asian IME?

[英]How to disable Asian IME for QTextEdit?

我正在用PyQt4开发语言学习系统,并为程序中可用的每种语言编写了一个嵌入式虚拟键盘。 我现在仅在Windows上测试该程序。 问题在于,当选择了亚洲IME(例如MS New Quick,Google拼音,搜狗,仓jie等)时,我无法摆脱它,当焦点位于QTextEdit时,它会继续覆盖所有按键。

我在继承QTextEdit时尝试了以下方法:

self.setAttribute(Qt.WA_InputMethodEnabled, False)

尝试在我的子类中重写inputMethodEventinputMethodQuery 当然, keyPressEvent被覆盖,否则我将无法实现虚拟键盘。

我也试过这个:

class customInputContext(QInputContext):

    def __init__(self, parent = 0):
        QInputContext.__init__(self, parent)
        print('qinputcontext initialized')

    def reset(self):
        pass

    def filterEvent(self, event):
        if event.type()==QEvent.RequestSoftwareInputPanel:
            print('input panel requested')
            event.accept()
            return QInputContext.filterEvent(self, event)
        else:
            return QInputContext.filterEvent(self, event)

class MyQApplication(QApplication):

    def __init__(self, args):
        QApplication.__init__(self, args)
        self.setInputContext(customInputContext(parent = self))
        self.setAutoSipEnabled(False)

而且,当我尝试在QTextEdit键入内容时,我始终会看到IME面板。 那么,当我不需要IME时,如何禁用它呢?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM