¿Vinculando el evento "enter" de QLineEdit a un espacio?

I do have the following code:

def init_widgets(self):
        mainLayout = QtGui.QGridLayout()

        self.label1 = QtGui.QLabel("Enter a song name: ")
        self.search_lineEdit = QtGui.QLineEdit()
        self.search_button = QtGui.QPushButton("&Search") # QCommandLinkButton
        self.search_button.clicked.connect(self.search_slot)
        self.table = self.createTable()
        self.label2 = QtGui.QLabel("iQuality v1.00 by Itay Brandes")

        mainLayout.addWidget(self.label1, 0, 0)
        mainLayout.addWidget(self.search_lineEdit, 0, 1)
        mainLayout.addWidget(self.search_button, 0, 2)
        mainLayout.addWidget(self.table, 1, 0, 1, 0)
        mainLayout.addWidget(self.label2, 2, 0)

        self.setLayout(mainLayout)

Como puedo correr self.search_slot if the user presses the enter button on self.search_lineEdit?

preguntado el 10 de marzo de 12 a las 15:03

1 Respuestas

QLineEdit tiene un returnPressed signal. You can connect that signal from search_lineEdit to your custom slot.

Not familiar with the PyQt syntax, but should be something like:

 self.search_lineEdit.returnPressed.connect(self.search_slot)

respondido 10 mar '12, 15:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.