QT learning day1

1. Understand the
advantages of QT 1.1
1.1.1 is a cross-platform language
1.1.2. Simple interface, easy to use
1.1.3. A certain program simplifies memory recovery
1.2 version
1.2.1 commercial version
1.2.2 open source version
1.3 success Case
1.3.1 Linux desktop environment KDE
1.3.2 Google Maps
1.3.3 VLC multimedia player
2. Create a QT program
2.1 After clicking to create a project, select the project path and give the project a name.
2.2 Name: No Chinese path, no spaces
2.3 Path: No Chinese path
2.4 Create window class by default, myWidget, base class has three choices: QWidget, QMainWidget, QDialog
2.5 main function
2.5.1 QApplication a application object, yes And there is only one
2.5.2 myWidget w instantiated window object (the window will not be displayed by default)
2.5.3 Call the show() method to display the window
2.5.4 return a.exec() Let the application object enter the message loop mechanism , The code is blocked to the current line
3. Common APIs of button controls
3.1 Create QPushButton *btn=new QPushButton;
3.2 Set parent set parent(this);
3.3 Set the text set text("button")
3.4 Set the position set move(100,200)
3.4 Re-specify the size of the window resize()
3.5 Reset the title of the window setWindowTitle
3.6 Set the fixed size of the window setFixedSize
4 Object tree
4.1 When the created object is in In the heap area, if the specified parent is a subclass derived from QObject or a class derived from QObject subclass, you can put the object in the object tree without managing the release mechanism.
4.2 Simplifies the memory recovery mechanism to a certain extent.
5 QT's Coordinate system
5.1 The upper left corner is the (0,0) point
5.2 x is the positive direction on the right, and y is the positive direction below
6 The relationship between the signal and the slot
Insert picture description here
6.1 Connect function connect
6.2 Parameters
6.2.1 Parameter 1 The sender of the signal
6.2.2 Parameter 2 The signal sent (function address)
6.2.3 Parameter 3 The receiver of the signal
6.2.4 Parameter 4 The function processed (function address)
6.3 Loose coupling
6.4 Click the button in the experiment and close the window case
6.5 connect(btn ,&QPushButton:: click,this,&QWidget::close);
7. Custom signals and slots
7.1 Sub-defined signals
7.1.1 The return value is void
7.1.2 Only need to declare, no need to implement
7.1.3 Can be written under signal
7.2 Sub-defined slot
7.2.1 The return value is void
7.2.2 Need to declare, also need to be realized
7.2.3 Can have parameters, can be overloaded
7.2.4 Can be written in public slot or public or global under

Guess you like

Origin blog.csdn.net/qq_40637881/article/details/108610221