I am making the following GUI with PySide, but I am stumbling.
・ Multiple QLineEdits are installed
-After entering a number, press Enter to move the focus to the next QLineEdit.
I was able to define a keyPressEvent as shown below and press Enter to move the focus.
I can no longer enter (display) anything in QLineEdit, including numbers.
def keyPressEvent (self, event): if event.key () == Qt.Key_Enter: print ("Pressed Enter") self.input [self.n + 1] .setFocus () # Move focus to next QLineEdit
I tried and errored to accept the input, but it didn't work.
Can anyone give me some advice?
Answer # 1
Create a class that inherits QLineEdit,
keyPressEventDid you override the method?
keyPressEventSince the process is being intercepted by overriding, the original process is not performed.
Let's call the original processing properly.
#coding: utf-8 import sys from PySide2.QtWidgets import * from PySide2.QtCore import * from PySide2.QtGui import * class MyLineEdit (QLineEdit): def keyPressEvent (self, event): print ('keyPressEvent, key =% s.'% Event.key (), flush = True) if event.key () == Qt.Key_Return: print ('enter.', flush = True) else: else: # If you do not handle it, execute the process of the override source super (). keyPressEvent (event) if __name__ =='__main__': app = QApplication (sys.argv) window = MyLineEdit () window.show () sys.exit (app.exec_ ())
- python 3x - i want to output the name corresponding to the number entered in the excel file
- python - i'm using selenium the text sent by send_keys to the input tag disappears when the text is sent by send_key to the next
- python sarimax how to input exogenous variables (error check request)
- python - valueerror: field'id' expected a number but got'suzukitadashi'
- where is the minor version number of python that starts by default specified?
- python - when you want to judge by the number of characters from the back with a regular expression
- python - how to get the number of searches for a specific word within the period
- python - sumy by specifying the maximum number of characters with sumy
- python - i want to add a line number to the data frame
- number of python combinations
- about errors in python input
- (python) input () if time elapses without input, skip input () and move to the next process what can i do?
- i want to invert the number 12345 in python like 54321 and display it
- python - i want to write light text in the input box
- python - valueerror: error when checking input: expected input_1 to have 4 dimensions,
- get the number of characters from the python text box
- get the total number and name of python grouping
- how to align the number of elements with overlaplengt of python etc
- python - about input error
- python : Switch Bar in PyQt5
- python : Animating button rotation on hover pyqt5
- python : how to set the initial size of a QFrame?
- python : Working with QDelegate
- python : Error creating QfileDialog by clicking button to select file
- python : How to get a response if at least one of the CheckBoxes in a QGroupBox changes its state (PyQt5)
- python : Binding values to a dropdown list from a QComboBox