I. API Interface Settings
For example, I have some settings in this code, set the text, center it, disable copying, LineEdit input as password, etc.
import sys from import Qt from import QFrame from import QLabel from import QWidget from import QLineEdit from import QTextEdit from import QSizePolicy from import QMainWindow from import QPushButton from import QGridLayout from import QApplication from View import interface class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init__(None) ("Corrosion to metal tester") () def initUI(self): layout = QGridLayout() (10) = QLabel("Username:") () ("color:rgb(20,20,20,255);font-size:16px;font-weight:bold:text") = QLineEdit() ("admin") ("User Name") (True) = QLabel("Password:") () = QLineEdit() () #Disable copy and paste ("Password") ("admin") () (True) = QPushButton("Register.") = QPushButton("Landing.") = QLabel("User Login") (300,30) () ("color:rgb(10,10,10,255);font-size:25px;font-weight:bold;font-family:Roman times;") (,) (,0,0,1,2) policy = () print(()) (1) print(()) # (1) (,1,0) (,1,1) (,2,0) (,2,1) (,3,0) (,3,1) frame = QFrame(self) (layout) (frame) (300,150) if __name__ == '__main__': app = QApplication() mainWindow = MainWindow() () () mainWindow.raise_() app.exec_() del mainWindow del app
1.1.0 Some properties of QLineEdit
inputMask sets the mask
text Sets the text
maxLength Maximum number of characters to be entered in the text box.
frame Sets the border.
echoMode sets the text box display format
Normal displays the entered characters normally, which is the default option.
NoEcho doesn't show any input characters, commonly used for password type input, and length confidentiality
Password displays the password mask characters associated with the platform, not the actual characters typed
PasswordEchoOnEdit displays characters during editing and is responsible for displaying the password type entry
cursorPosition
alignmentText alignment
AlignLeft
AlignRight
AlignCenter Horizontal Center Alignment
AlignJustify Horizontal Adjustment Spacing Align Both Ends
AlignTop vertical alignment
AlignBottom Vertical Alignment
AlignVCenter Vertical Center Alignment
dragEnabled sets whether the text box accepts dragging.
readOnly sets the text to read-only.
placeholderText set textbox hint text
cursorMoveStyle cursor move style
LogicalMoveStyle Logical Style
VisualMoveStyle visual style
clearButtonEnabled Quick Delete Button
Reference articles, QLineEdit properties, signals, methods, etc.
1.1 Some common settings
parameters | corresponds English -ity, -ism, -ization |
---|---|
AlignAbsolute=16 | |
AlignBaseline=256 | |
AlignBottom=64 | Bottom Alignment |
AlignCenter=132 | perfectly centered |
AlignHCenter=4 | horizontal centering |
AlignHorizontal_Mask=31 | |
AlignJustify=8 | Free Space Alignment |
AlignLeading=1 | Collar alignment (read that as left alignment, I guess) |
AlignLeft=1 | left justification |
AlignRight=2 | right-aligned |
AlignTop=32 | top-aligned |
AlignTrailing=2 | End-aligned (right-aligned) |
AlignVCenter=128 | vertical centering |
setClearButtonEnabled(self, bool): if or not there is a clear text button (e.g. the little black X after the text box in my first program)
setCompleter(self, QCompleter):set autocompleteQLineEdit AutoComplete
setCursorMoveStyle(self, Qt_CursorMoveStyle):
setCursorPosition(self, p_int):
setDragEnabled(self, bool):
setEchoMode(self, QLineEdit_EchoMode):
setFrame(self, bool):
setInputMask(self, p_str):
setMaxLength(self, p_int):
setModified(self, bool):
setPlaceholderText(self, p_str):
setReadOnly(self, bool):
setSelection(self, p_int, p_int_1):
setText(self, p_str):
setTextMargins(self, *__args):
setValidator(self, QValidator):
This article on the realization of PyQt5 control font styles and other settings are introduced to this article, more related PyQt5 control font styles, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!