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

QGraphicsView constructor overriding InputMethod enabling.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 4.6.1
    • Widgets: GraphicsView
    • None
    • window/symbian/linux

    Description

      I am using Qt 4.6.1 version, and found a bug in the constructor of QGraphicsView.

      originalcode
       QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
          : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
      {
          setScene(scene);
          setViewport(0);
          setAcceptDrops(true);
          setBackgroundRole(QPalette::Base);
          // Investigate leaving these disabled by default.
          setAttribute(Qt::WA_InputMethodEnabled);
          viewport()->setAttribute(Qt::WA_InputMethodEnabled);
      }
      
      

      As SetScene updates the Qt::WA_InputMethodEnabled flag internally and it is overridden by the next lines to true.

      And when control reaches to the QApplication (when the first time QGraphicsView launched), QApplication calls QInputContext::setFocusWidget(view_pointer) even if there is no focused item inside the QGraphicsScene, which I feel is not correct. And this is done before sending the focusinevent to the QGraphicsView, so view didn't get a change to update inputmethod sensitivity.

      A fix could be.

      Fix
      QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
          : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
      {
          setScene(scene);
          setViewport(0);
          setAcceptDrops(true);
          setBackgroundRole(QPalette::Base);
      }
      
      

      Easy to reproduce. Just write below code.

      test app
      QGraphicsScene scene;
      QGraphicsView view(&scene);
      view.show();
      

      And put a break point in the QWinInputContext::setFocusWidget(QWidget *w) if you are on windows system.

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            manishsharma Manish Sharma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes