当前位置:网站首页>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();
}
边栏推荐
- Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
- The beauty of Mathematics -- the principle of fine Fourier transform
- Matlab code on error analysis (MAE, MAPE, RMSE)
- General configuration title
- About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
- 4. Apprentissage stratégique
- Taiwan Xinchuang sss1700 latest Chinese specification | sss1700 latest Chinese specification | sss1700datasheet Chinese explanation
- The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
- Micro rabbit gets a field of API interface JSON
- Codeforces Round #804 (Div. 2)
猜你喜欢
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
2022 free test questions of fusion welding and thermal cutting and summary of fusion welding and thermal cutting examination
Problems of font legend and time scale display of MATLAB drawing coordinate axis
The solution of frame dropping problem in gnuradio OFDM operation
Gnuradio transmits video and displays it in real time using VLC
LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表
Redis cluster
On the concept and application of filtering in radar signal processing
Vs code configuration latex environment nanny level configuration tutorial (dual system)
Smart grid overview
随机推荐
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
qt--将程序打包--不要安装qt-可以直接运行
2022 safety officer-b certificate examination question bank and safety officer-b certificate simulation test questions
2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
Leetcode notes No.21
Four digit nixie tube display multi digit timing
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
Ag9311maq design 100W USB type C docking station data | ag9311maq is used for 100W USB type C to HDMI with PD fast charging +u3+sd/cf docking station scheme description
USB type-C mobile phone projection scheme | USB type-C docking station scheme | TV / projector type-C converter scheme | ag9300ag9310ag9320
Plot function drawing of MATLAB
Redis cluster
Chapter 16 intensive learning
2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions
Leetcode notes No.7
The usage of rand function in MATLAB
2021-04-12 - new features lambda expression and function functional interface programming
Codeforces Round #804 (Div. 2)
写一个纯手写的qt的hello world
Micro rabbit gets a field of API interface JSON
Use "recombined netlist" to automatically activate eco "APR netlist"