当前位置:网站首页>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();
}

边栏推荐
- Problems of font legend and time scale display of MATLAB drawing coordinate axis
- 4. Strategic Learning
- The beauty of Mathematics -- the principle of fine Fourier transform
- Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
- Led serial communication
- Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
- 2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
- On the concept and application of filtering in radar signal processing
- Kaptcha generates verification code on Web page
- Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
猜你喜欢

2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search

Vs code configuration latex environment nanny level configuration tutorial (dual system)

2021-04-12 - new features lambda expression and function functional interface programming

Solve the error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.

High quality USB sound card / audio chip sss1700 | sss1700 design 96 kHz 24 bit sampling rate USB headset microphone scheme | sss1700 Chinese design scheme explanation

Two methods for full screen adaptation of background pictures, background size: cover; Or (background size: 100% 100%;)

2022 safety officer-b certificate examination question bank and safety officer-b certificate simulation test questions

Ag9310 design USB type C to hdmi+u2+5v slow charging scheme design | ag9310 expansion dock scheme circuit | type-C dongle design data

Basic realization of line chart (II)

Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
随机推荐
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
Multi purpose signal modulation generation system based on environmental optical signal detection and user-defined signal rules
5. Over fitting, dropout, regularization
Kafka-connect将Kafka数据同步到Mysql
Matlab code about cosine similarity
NPM internal split module
解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
Problems of font legend and time scale display of MATLAB drawing coordinate axis
4. Apprentissage stratégique
LaTeX 中 xcolor 颜色的用法
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
写一个纯手写的qt的hello world
Redis 主从复制
Gnuradio3.9.4 create OOT module instances
8. Optimizer
The difference between distribution function and probability density function of random variables
3. Multi agent reinforcement learning
Taiwan Xinchuang sss1700 latest Chinese specification | sss1700 latest Chinese specification | sss1700datasheet Chinese explanation