擅长:python、mysql、java
<p>您要查找的方法名为<a href="http://srinikom.github.com/pyside-docs/PySide/QtGui/QWidget.html#PySide.QtGui.PySide.QtGui.QWidget.keyPressEvent" rel="nofollow">^{<cd1>}</a>,而不是<code>KeyPressEvent</code>。在</p>
<hr/>
<p>这似乎是在偷你的事件。如果您只想处理行edit中的enter键,那么可以将<code>returnPressed</code>信号连接到<code>self.fun</code>:</p>
<pre><code>self.text.returnPressed.connect(self.fun) # in PySide
</code></pre>
<p>否则,您将不得不处理<a href="http://srinikom.github.com/pyside-docs/PySide/QtCore/QObject.html#PySide.QtCore.PySide.QtCore.QObject.installEventFilter" rel="nofollow">event filters</a>。稍后我会尝试发布一些代码。在</p>
<hr/>
<p>你最后的编辑更清楚了。{cd1>你可以安全地使用}:</p>
^{pr2}$
<p>这是一个多么混乱的答案:)</p>