Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1664

chinese input method problem when the qgrpahicstextedit was used in sub view

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.15.2
    • PySide
    • None
    • Pycharm(python 3.9.6)
    • Windows

    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_()
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            lala lala looo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes