Understanding QT signals and slots

Enter the QT official website, register, create an account, and log in;

Download the online installer; 10-day trial version; installation; upon completion, as follows;

Create a new widgets project, which is a window application on the desktop;

 

Follow the wizard to create a new and completed project;

 

.ui This is the interface description file. Double-click this file, or the design button in the first column on the left to enter the interface design environment;

 

Put a button and a Text Edit; then take a look, the signal and slot editor is below the design interface;

 

Click the plus sign to add a row; select the object through the drop-down; the sender selects the button; the signal selects clicked(); the receiver selects textEdit; then look at the slot, pull down to see the various functions that the edit box can execute; slot first selectselectAll();

 

From this point of view, the sender is a component, it is called a widget, and widget in English means small appliances and small devices; the signal is a certain behavior of the sender, such as click, double-click, etc.; the receiver is also a widget; the slot is the receiving A function that can be executed by

Its definition is this: when a specific event occurs, a signal is emitted; a slot is a function that can be called to handle a specific signal;

Double-click textEdit to pop up the content editing interface; it looks like a rich text control; edit some content and confirm;

 

The interface now is as follows;

 

Run the program; click the button and all content in textEdit is selected;

 

Guess you like

Origin blog.csdn.net/bcbobo21cn/article/details/133057781