[英]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.