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

边栏推荐
- Chapter 5 neural network
- Redis 主从复制
- General configuration tooltip
- Introduction to natural language processing (NLP) based on transformers
- Chapter IV decision tree
- 2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
- Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
- 2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
- 2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
- Use "recombined netlist" to automatically activate eco "APR netlist"
猜你喜欢

4. Apprentissage stratégique
![Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small](/img/ab/066923f1aa1e8dd8dcc572cb60a25d.jpg)
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small

Several frequently used OCR document scanning tools | no watermark | avoid IQ tax

Design method and application of ag9311maq and ag9311mcq in USB type-C docking station or converter

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

2022 safety officer-c certificate examination paper and safety officer-c certificate simulated examination question bank

Vscode reading Notepad Chinese display garbled code

Understanding of prior probability, posterior probability and Bayesian formula

Chapter 5 neural network

The solution of frame dropping problem in gnuradio OFDM operation
随机推荐
5. Over fitting, dropout, regularization
Basic implementation of pie chart
Chapter improvement of clock -- multi-purpose signal modulation generation system based on ambient optical signal detection and custom signal rules
NPM Internal Split module
2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem
The beauty of Mathematics -- the principle of fine Fourier transform
A speed Limited large file transmission tool for every major network disk
Ag7120 and ag7220 explain the driving scheme of HDMI signal extension amplifier | ag7120 and ag7220 design HDMI signal extension amplifier circuit reference
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
How does Matplotlib and PIL image integrate and save multiple pictures into one picture
Connect to the previous chapter of the circuit to improve the material draft
2022 safety officer-a certificate free examination questions and safety officer-a certificate mock examination
2022 free test questions of fusion welding and thermal cutting and summary of fusion welding and thermal cutting examination
Redis集群
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
Scalar / vector / matrix derivation method
Chapter IV decision tree