setFocusPolicy(Qt::StrongFocus); // Tab focus order Click focus: 按下Tab鍵或者鼠標(biāo)點(diǎn)擊獲得焦點(diǎn).
使一個(gè)控件始終得到鍵盤輸入, 不管點(diǎn)了什么地方:
void QWidget::grabKeyboard ()
Grabs the keyboard input.
This widget receives all keyboard events until releaseKeyboard() is called; other widgets get no keyboard events at all. Mouse events are not affected. Use grabMouse() if you want to grab that.
The focus widget is not affected, except that it doesn't receive any keyboard events. setFocus() moves the focus as usual, but the new focus widget receives keyboard events only after releaseKeyboard() is called.
If a different widget is currently grabbing keyboard input, that widget's grab is released first.