Basic knowledge of qt5, qt5

Source: Internet
Author: User

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.



 





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.