I thought that when pressing the enter key on a QLineEdit, it would remove the focus (and the cursor wouldn't be visible anymore).
For some reason it doesn't behave that way in this simple example. Can somebody explain why?

Qt Code:
  1. LineEditTest::LineEditTest(QWidget *parent)
  2. : QWidget(parent)
  3. {
  4. QLineEdit *edit = new QLineEdit;
  5. Q_ASSERT(connect(edit, SIGNAL(editingFinished()), this, SLOT(SlotTextEdited())));
  6.  
  7. l->addWidget(edit);
  8. setLayout(l);
  9. }
  10.  
  11.  
  12. void LineEditTest::SlotTextEdited()
  13. {
  14. QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(sender());
  15. double value = lineEdit->text().toDouble();
  16. ...
  17. // lineEdit->clearFocus(); // If this line is enabled the cursor disappears
  18. }
To copy to clipboard, switch view to plain text mode