M
M
Miri_Skava2019-05-23 19:11:36
Python
Miri_Skava, 2019-05-23 19:11:36

How to handle keyboard key presses in QLineEdit?

Hello!
Please tell me how to set the action on pressing a keyboard key in QLineEdit. There is a way to do this for the window, but I couldn’t find any information for doing it with other objects

import sys  
from PyQt5 import QtCore, QtGui, QtWidgets
import start_menu, dialog, login, registration
import mysql.connector
import random
import datetime

class Reg(QtWidgets.QDialog, registration.Ui_registration):
        def __init__(self):
            super().__init__()
            self.setupUi(self) 
        def keyPressEvent(self, event):
            self.timebetween.setText(str("dd")
            event.accept()
..........

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2019-05-23
@Miri_Skava

When changing the text inside QLineedit, the signal is emitted textChanged(text: str). The parameter is the text contained in the field. Subscribe and edit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question