KylinOS V4 下 Qt5.6.1 QPlainTextEdit 设置只读再取消只读后不能输入汉字的问题

问题:Phytium/FT-2000 | KylinOS V4 平台 使用Qt 5.6.1 开发图形界面的应用程序,使用了QPlainTextEdit 控件,在调用该控件的 setReadOnly(true)后,再调用 setReadOnly(false)之后,在该控件内输入文本时就不能输入汉字了。更具体来说,上述操作后,热点在此控件时,无法切换输入法;即使上述操作前,事先切换到中文输入法,在输入的时候,控件内直接显示输入的英文字符。

分析:

bing搜索"qt qplaintextedit输入中文",其中类似的一个链接是qt qplaintextedit输入中文_QQuickWidget中文输入法问题的正确解法_柯布西耶的博客-CSDN博客QQuickWidget中文输入法问题的正确解法本文分享特定问题的解法,用不到的可以忽略。Qt的bug使用QQuickWidget的时候,遇到过这个问题:界面的TextInput 或者TextEdit, 鼠标点击聚焦后,切换为光标输入状态,此时切换系统中文输入法,会发现无法输入。(系统任务栏的输入法状态是正确的,界面上输入字符,直接显示英文,无法显示输入法的候选框)需要把界面切到其它软件,再切换回...https://blog.csdn.net/weixin_28704239/article/details/113314537看内容有点小麻烦。

bing再搜索“qplaintextedit cannot input chinese after set readonly”,返回的一条类似的链接是

Input disable with Chinese IME starting from QON windows-b3623 · Issue #976 · pbek/QOwnNotes · GitHubicon-default.png?t=LA92https://github.com/pbek/QOwnNotes/issues/976提到:

vanleo2001 commented Jul 25, 2018

Please review this QT5 bug: [QTBUG-55699] Japanese IME is disabled for QPlainTextEdit after read-only flag is toggled - Qt Bug Tracker
I build and run the Attachments in this bug report. After click the button to set QPlainTextEdit read-only flag as True , then set as False, Japanese IME can only input English charactor.
This is same as QON. When the default first note opens, QPlainTextEdit has set read-only TWICE (First is False, Second isTrue). So this is a QT5 bug, it affects Version/s: 5.6.1, 5.7.0, and not fix. But according QON, maybe we can fix it in our code if we set read-only 3 times: False-True-True.

 嗯,有启发。

 解决:在代码中,把需要调用setReadOnly()的位置,连续调用两次setReadOnly(),测试恢复正常,可以随心所欲输入汉字了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值