Basic knowledge of qt5, qt5
QWidget w
QLineEdit edit;
Edit. show (); // if no such sentence exists, the edit box is displayed in the upper left corner of the parent window.
Edit. setParent (& w); // use w as the parent window and display it above
W. show ();
Qconnect (& button, SIGNAL (clicked (), & w, SLOT (close (); // click the button to close the w window. W is an object and w is a window.
Exclusive QLineEdit usage
QLineEdit edit;
Edit. setText ("show text"); // display text in the edit box
Edit. setEchoMode (QLineEdit: password); // The entered password is automatically circled.
Edit. setEchoMode (QLineEdit: passwordEchoOnEdit); // The entered password turns into a circular pattern after being defocus.
Account matching mode (enter a number to display the entire account)
QCompleter completer (StringList () <"598265430" <"1710514175 ");
Completer. setFilterMode (Qt: MatchContains); // match any contained content
Edit. setcompleter (& completer); // match all strings above the completer in the edit box. It can only start with the first character.
Set the widget location
Edit. setGeometry (30,30, 100,30); // x, y, long, high is not very good
QHBoxLayout layout; // QH indicates that the horizontal QV is vertical.
Layout. addStretch (1); // fixed position with spring
Layout. addWidget (& button );
Layout. addspacing (50); // 50 pixels are separated in the middle
layout.addWidget(&edit);
Layout. addStretch (1); // fixed position with spring
W. setLayout (& layout );
Layout can help you set up the parent-child relationship by yourself. You can omit the above setparent.
QGridlayout class (grid class)
QGridlayout layout;
Layout. setColumnStretch (3, 1); // column spring
Layout. setRowStretch (); // The row spring
layout.setColumnStretch(0,1);
layout.setRowumnStretch(0,1);
layout.addwidget(&button,1,1);
layout.addwidget(&edit,1,2);
layout.addwidget(new Qpushbutton("a"),2,1);
Layout. addwidget (new Qpushbutton ("B"), 2, 2 );
Layout. addwidget (new Qpushbutton ("merge"),); // The following two parameters are merged into one row and two columns.