当前位置:网站首页>Write a pure handwritten QT Hello World
Write a pure handwritten QT Hello World
2022-07-08 01:28:00 【bin elf】


Realization effect : Empty item


Then add the file in the project file 

Realize the compilation of window and button controls
#include <QApplication>
#include <QWidget> // Reference header file Window file base class
#include <QPushButton> // Button controls
int main(int argc, char *argv[])
{
// Objects with and only one application class --- Even if there are many windows
QApplication a(argc, argv);
// Create a blank window
QWidget w;
w.setWindowTitle(" Window for Yang ");// Set title
// Show
w.show();
// Create button
QPushButton b;
b.setText(" Yang's exclusive button ");// Give the button facility content
b.show();// Give space that shows
/* If you do not specify a parent object Objects and objects ( Windows and windows ) It doesn't matter. , It's independent
*a Appoint b For its parent amount to a stay b On ( The son is above the father )
* So this case needs to specify that the window is the parent object Buttons are sub objects There are two ways
* 1)setParent
* 2) Constructor arguments
* Benefits of specifying a parent , You just need the parent object to display The sub objects above are automatically displayed */
return a.exec();
}
There are two windows

Realize a window display
#include <QApplication>
#include <QWidget> // Reference header file Window file base class
#include <QPushButton> // Button controls
int main(int argc, char *argv[])
{
// Objects with and only one application class --- Even if there are many windows
QApplication a(argc, argv);
// Create a blank window
QWidget w;
w.setWindowTitle(" Window for ");// Set title
#include <QApplication>
#include <QWidget> // Reference header file Window file base class
#include <QPushButton> // Button controls
int main(int argc, char *argv[])
{
// Objects with and only one application class --- Even if there are many windows
QApplication a(argc, argv);
// Create a blank window
QWidget w;
w.setWindowTitle(" Window for younger sister Yang ");// Set title
// Create button 1
QPushButton b;
b.setText(" Yang's exclusive button ");// Give the button facility content
b.setParent(&w); // Specify the husband object It is displayed in the upper left corner The display effect is not good
// Change effect
b.move(100,100);// Moving pixels
// Create button 2
QPushButton b1(&w); // Constructor arguments Specify the parent object
b1.setText("abc");// Give the button facility content
w.show();// Give space that shows
/* If you do not specify a parent object Objects and objects ( Windows and windows ) It doesn't matter. , It's independent
*a Appoint b For its parent amount to a stay b On ( The son is above the father )
* So this case needs to specify that the window is the parent object Buttons are sub objects There are two ways
* 1)setParent
* 2) Constructor arguments
* Benefits of specifying a parent , You just need the parent object to display The sub objects above are automatically displayed */
return a.exec();
}
// Create button 1
QPushButton b;
b.setText(" Yang's exclusive button ");// Give the button facility content
b.setParent(&w); // Specify the husband object It is displayed in the upper left corner The display effect is not good
// Change effect
b.move(100,100);// Moving pixels
// Create button 2
QPushButton b1(&w); // Constructor arguments Specify the parent object
b1.setText("abc");// Give the button facility content
w.show();// Give space that shows
/* If you do not specify a parent object Objects and objects ( Windows and windows ) It doesn't matter. , It's independent
*a Appoint b For its parent amount to a stay b On ( The son is above the father )
* So this case needs to specify that the window is the parent object Buttons are sub objects There are two ways
* 1)setParent
* 2) Constructor arguments
* Benefits of specifying a parent , You just need the parent object to display The sub objects above are automatically displayed */
return a.exec();
}

边栏推荐
- QT--创建QT程序
- Basic realization of line chart (II)
- Recommend a document management tool mendely Reference Manager
- Kaptcha generates verification code on Web page
- Understanding of expectation, variance, covariance and correlation coefficient
- Led serial communication
- 写一个纯手写的qt的hello world
- AttributeError: ‘str‘ object has no attribute ‘strftime‘
- Call (import) in Jupiter notebook ipynb . Py file
- Chapter 5 neural network
猜你喜欢

Chapter XI feature selection

The persistence mode of redis - RDB and AOF persistence mechanisms

5、离散控制与连续控制

2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills

Led serial communication

Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds

Matlab code about cosine similarity

Cs5212an design display to VGA HD adapter products | display to VGA Hd 1080p adapter products

The combination of relay and led small night light realizes the control of small night light cycle on and off

Share a latex online editor | with latex common templates
随机推荐
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
2、TD+Learning
The beauty of Mathematics -- the principle of fine Fourier transform
qt--将程序打包--不要安装qt-可以直接运行
2、TD+Learning
Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
2021-03-14 - play with generics
Different methods for setting headers of different pages in word (the same for footer and page number)
Redis 主从复制
Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
Know how to get the traffic password
Vscode is added to the right-click function menu
4. Strategic Learning
Measure the voltage with analog input (taking Arduino as an example, the range is about 1KV)
Matlab code on error analysis (MAE, MAPE, RMSE)
2021-03-06 - play with the application of reflection in the framework
写一个纯手写的qt的hello world
5. Discrete control and continuous control
NPM Internal Split module