Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.15.2
-
None
-
Pycharm(python 3.9.6)
Description
Here is my example(the input method not working): I create a qgraphicsview and a root scene with it. Then I create a qgraphicsview again with QGraphicsProxyWidget to add it into the root scene, then the input method not works. But if I add the qgraphicstextitem directly into the root scene, the chinese input method works.
When I check inputMethodEvent of the qgraphicstextitem, it was never called.
More info:
- My chinese input method is Microsoft Tranditional Chinese IME.
- When I was typing, keyPressEvent of QGraphicsTextItem was called, not inputMethodEvent.
- This focus widget of root view and root scene is never changed when I do something in sub view. The focus widget in this case:
- root view: root view itself
- root scene: proxy
- sub view: sub view itself
- sub scene: text
from PySide2 import QtCore, QtWidgets app = QtWidgets.QApplication([]) # create root view root_view = QtWidgets.QGraphicsView() root_scene = QtWidgets.QGraphicsScene() root_view.setScene(root_scene) # create proxy widget to add the sub view into the root scene proxy = QtWidgets.QGraphicsProxyWidget() proxy.setFlag(QtWidgets.QGraphicsItem.ItemAcceptsInputMethod) sub_view = QtWidgets.QGraphicsView() sub_view.setAttribute(QtCore.Qt.WA_InputMethodEnabled) sub_scene = QtWidgets.QGraphicsScene() sub_view.setScene(sub_scene) # create QGraphicsTextItem text = QtWidgets.QGraphicsTextItem('hello') text.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction) text.setFlag(QtWidgets.QGraphicsItem.ItemAcceptsInputMethod) # added into root scene sub_scene.addItem(text) proxy.setWidget(sub_view) root_scene.addItem(proxy) # run the application root_view.show() app.exec_()