[英]QLineEdit the function selectAll() didn't work?
我这样使用QLineEdit,任何人都知道有什么问题:
if (event->modifiers() == Qt::ControlModifier
&& event->key()== Qt::Key_A) {
qDebug() << "Ctrl+A pressed";
m_lineEdit->setFocus(Qt::ShortcutFocusReason);
m_lineEdit->selectAll();
}
尝试使用计时器确保所有事件都已处理,然后完成选择:
QTimer::singleShot(0, m_lineEdit, SLOT(selectAll()));
而不是m_lineEdit->selectAll()
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.