-3
How do I open a function by pressing the F10 key on a Qlineedit?
Searching found the function "returnPressed" but only works for the "Enter"
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(612, 430)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lin1 = QtWidgets.QLineEdit(self.centralwidget)
self.lin1.setGeometry(QtCore.QRect(20, 130, 113, 20))
self.lin1.setObjectName("lin1")
self.lin2 = QtWidgets.QLineEdit(self.centralwidget)
self.lin2.setGeometry(QtCore.QRect(150, 130, 113, 20))
self.lin2.setObjectName("lin2")
self.lin3 = QtWidgets.QLineEdit(self.centralwidget)
self.lin3.setGeometry(QtCore.QRect(290, 130, 113, 20))
self.lin3.setObjectName("lin3")
self.lin4 = QtWidgets.QLineEdit(self.centralwidget)
self.lin4.setGeometry(QtCore.QRect(430, 130, 113, 20))
self.lin4.setObjectName("lin4")
MainWindow.setCentralWidget(self.centralwidget)
# -----------------------------------------------------------------
self.lin1.returnPressed.connect(self.teste)
# -----------------------------------------------------------------
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def teste(self):
print('Tecla ENTER pressionada')
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
Hello Rafael. Do not use the field "Your answer" to thank, you "thank" marking the answer as correct by clicking on the icon that is next to my answer. If you have any questions please follow the tips by: https://pt.meta.stackoverflow.com/a/1079/3635
– Guilherme Nascimento