Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.5.2
-
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();
}