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

QGraphicsView/QLineEdit/cursor issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.5.3
    • 4.5.2
    • Widgets: GraphicsView
    • None
    • 2841ac47dbd646539cc863a030be4a0ac6a077f4

    Description

      The following example reproduces a problem with line edits on QGraphicsView.

      The line edit in the example gets focus but doesn't display a blinking cursor.

      If one changes the #if 0 to an #if 1 it works. In the regular widget case it does work without having to explicitly send the focusIn event.

      #include <QtGui>

      #define GRAPHICSVIEW
      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      #ifdef GRAPHICSVIEW // doesn't work
      QGraphicsScene scene;
      QGraphicsView w(&scene);
      QLineEdit *edit = new QLineEdit;
      scene.addWidget(edit);
      edit->setFocus();
      #if 0 // fixes it
      QFocusEvent event(QEvent::FocusIn);
      qApp->sendEvent(edit, &event);
      #endif
      w.show();
      #else // works
      QWidget w;
      QLineEdit *edit = new QLineEdit(&w);
      edit->setFocus();
      w.show();
      #endif

      return a.exec();
      }

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes