Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.14.2, 5.15.0, 6.0.0 Beta2
-
None
-
OS:Ubuntu 20.04 x86_64
Qt Version: Qt5.15.0 Qt6.0
Compiler: x86_64-linux-gnu
Executed from Qt Creator in Debug mode.
-
-
bf5011815d917e07ae7cf45e5768f1775f70e90d (qt/qtbase/dev) 7c77201b68bdda64ed25fcbdff46bd9710b378a3 (qt/qtbase/5.15)
Description
phenomenon:
- when use QGraphicsProxyWidget proxy QTextEdit or QLineEdit and type chinese;
- the fcitx-pinyin appear preview effect;
- when you click scence, inputMethod does not disappear;
- and up to now, i test has no preview inputMethod also has this error;
- i test for QGraphicsTextItem, QGraphicsTextItem work fine.
Recurrence steps:
- create QGraphicsScene and add QGraphicsProxyWidget;
- then QGraphicsProxyWidget add QTextEdit or QLineEdit(which can recive inputMethod)
- use fcitx-pinyin inputMethod type chinese and appear preview effect;
- click scence,but inputMethod does not disappear; (as you see, widget text is error QGraphicsProxyWidget work error)
Reason analysis:
- the reason why QGraphicsTextItem work fine is QGraphicsTextItem call function:
QApplication::inputMethod()->reset();
when** focusOutEvent and focusInEvent response.
- i am try to override QGraphicsProxyWidget focusOutEvent named MyQGraphicsProxyWidget, and add this test code:
if (this->widget()->testAttribute(Qt::WA_InputMethodEnabled)) QApplication::inputMethod()->reset();
it was work fine.the issue has been solved.(as you see, widget text is right QGraphicsProxyWidget work right)**
How to Edit with Qt:
- QGraphicsProxyWidget::focusInEvent and QGraphicsProxyWidget::focusOutEvent should be call QApplication::inputMethod()->reset() function , when proxy Widget has Qt::WA_InputMethodEnabled attribute;
- this edit method same as QGraphicsTextItem, inputMethod disappear or not, commit or not, it's up to inputMethod,but we need tell inputMethod we not use input or need reset inputMethod.
Appendix description:
- proxy.zip is test code demo;
- baiduInput.mp4 is use fcitx-baidu InputMethod which has no preview effect;
- pinyinInputmethod.mp4 is use fcitx-pinyin InputMethod which has preview effect;
- both of all use fcitx input.