Reputation: 53
I user QLineEdit like this, and anybody know anything is wrong:
if (event->modifiers() == Qt::ControlModifier
&& event->key()== Qt::Key_A) {
qDebug() << "Ctrl+A pressed";
m_lineEdit->setFocus(Qt::ShortcutFocusReason);
m_lineEdit->selectAll();
}
Upvotes: 0
Views: 386
Reputation: 5801
Try to use timer to make sure all events are processed and then selection is done:
QTimer::singleShot(0, m_lineEdit, SLOT(selectAll()));
instead of m_lineEdit->selectAll()
;
Upvotes: 0