Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122641

IME not working in nested QGraphicsView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.15.2, 6.6.3
    • Widgets: GraphicsView
    • None

    Description

       

      When I wrapping a QLineEdit in a QGraphicsProxyWidget to display in a QGraphicsView, it works fine and IME shows.

      However, if the QGraphicsView is in another QGraphicsScene, QLineEdit no longer gets focused and IME does not work anymore.

      behaviour: the first (top) box when typing chinese or japanese will open IME, but the second text box result doesn't show IME

      Here's a simple example.

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      #include <QGraphicsView>
      #include <QGraphicsScene>
      #include <QGraphicsProxyWidget>
      #include <QLineEdit>
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          QGraphicsView* parentView = new QGraphicsView();
          this->setCentralWidget(parentView);
          QGraphicsScene* parentScene = new QGraphicsScene();
          parentView->setScene(parentScene);
      
          QGraphicsView* childView = new QGraphicsView();
          QGraphicsScene* childScene = new QGraphicsScene();
          childView->setScene(childScene);
      
          QGraphicsProxyWidget* childProxy = new QGraphicsProxyWidget();
          childProxy->setWidget(childView);
          parentScene->addItem(childProxy);
      
          QLineEdit* edit = new QLineEdit();
          QGraphicsProxyWidget* editProxy = new QGraphicsProxyWidget();
          editProxy->setWidget(edit);
      
          QLineEdit* edit2 = new QLineEdit();
          QGraphicsProxyWidget* editProxy2 = new QGraphicsProxyWidget();
          editProxy2->setWidget(edit2);
      
          parentScene->addItem(editProxy); // Can focus and IME is showing
          childScene->addItem(editProxy2); // Doesn't get focused (to show cursor) and not showing IME
      
          setFixedSize(400, 300);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      } 

       

       

      Attachments

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

        Activity

          People

            bibr Andreas Aardal Hanssen
            hoongwei HongWei c
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes