擅长:python、mysql、java
<p>可能需要调用QWidget的方法<code>setFocusPolicy</code>来接收按键事件。
来自方法<i>keyPressEvent的<a href="http://doc.qt.nokia.com/latest/qwidget.html#keyPressEvent" rel="nofollow">QWidget</a>的API文档:</p>
<pre>
This event handler, for event <i>event</i>, can be reimplemented in a subclass
to receive key press events for the widget. A widget must call setFocusPolicy()
to accept focus initially and have focus in order to receive a key press event.
</pre>