pyqt eventfilter detects more than a single press
<p>I'm using <code>pyqt</code> and designed a window with <code>QTextEdit</code>. I added an event, but when I press enter it detects more than a single press. For example; when I press enter I want it to print 1. It does print 1, but not one time three times. </p>

<p>This is the eventfilter func:</p>

<pre><code>def eventFilter(self, source, event):
        if (type(event) == QtGui.QKeyEvent and event.key() == QtCore.Qt.Key_Return):
            if(not str(self.lineEdit.toPlainText()).isspace() and str(self.lineEdit.toPlainText())!="" ):
                data="YOU: " +str(self.lineEdit.toPlainText())
                self.my_socket.send(data)
                label=QtGui.QLabel()
                label.setText(data)
                label.setWordWrap(True)
                self.chat_layout.v_layout_container.addWidget(label)
                label.show()
                self.lineEdit.clear()
        return QtGui.QWidget.eventFilter(self, source, event)
</code></pre>