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?
LineEditTest
::LineEditTest(QWidget *parent
){
Q_ASSERT(connect(edit, SIGNAL(editingFinished()), this, SLOT(SlotTextEdited())));
l->addWidget(edit);
setLayout(l);
}
void LineEditTest::SlotTextEdited()
{
QLineEdit *lineEdit
= dynamic_cast<QLineEdit
*>
(sender
());
double value = lineEdit->text().toDouble();
...
// lineEdit->clearFocus(); // If this line is enabled the cursor disappears
}
LineEditTest::LineEditTest(QWidget *parent)
: QWidget(parent)
{
QLineEdit *edit = new QLineEdit;
Q_ASSERT(connect(edit, SIGNAL(editingFinished()), this, SLOT(SlotTextEdited())));
QHBoxLayout *l = new QHBoxLayout;
l->addWidget(edit);
setLayout(l);
}
void LineEditTest::SlotTextEdited()
{
QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(sender());
double value = lineEdit->text().toDouble();
...
// lineEdit->clearFocus(); // If this line is enabled the cursor disappears
}
To copy to clipboard, switch view to plain text mode
Bookmarks