当前位置:网站首页>写一个纯手写的qt的hello world
写一个纯手写的qt的hello world
2022-07-07 23:28:00 【bin elf】


实现效果:空项目


之后在项目文件中添加文件

实现了窗口和按钮控件的编写
#include <QApplication>
#include <QWidget> //引用头文件 窗口文件基类
#include <QPushButton> //按钮的控件
int main(int argc, char *argv[])
{
//有且只有一个应用程序类的对象---即使有很多个窗口
QApplication a(argc, argv);
//创建空白窗口
QWidget w;
w.setWindowTitle("给杨的窗口");//设置标题
//显示
w.show();
//创建按钮
QPushButton b;
b.setText("杨的专属按钮");//给按钮设施内容
b.show();//给空间认为显示
/*如果不指定父对象 对象和对象(窗口和窗口)没有关系,是独立的
*a指定b为它的父对象 相当于a在b上(子在父上面)
*所以本案例需要指定窗口是父对象 按钮是子对象 有两种方式
* 1)setParent
* 2)构造函数传参
*指定父对象的好处,只需要父对象显示 上面那的子对象自动显示*/
return a.exec();
}
是两个窗口

实现一个窗口显示
#include <QApplication>
#include <QWidget> //引用头文件 窗口文件基类
#include <QPushButton> //按钮的控件
int main(int argc, char *argv[])
{
//有且只有一个应用程序类的对象---即使有很多个窗口
QApplication a(argc, argv);
//创建空白窗口
QWidget w;
w.setWindowTitle("给的窗口");//设置标题
#include <QApplication>
#include <QWidget> //引用头文件 窗口文件基类
#include <QPushButton> //按钮的控件
int main(int argc, char *argv[])
{
//有且只有一个应用程序类的对象---即使有很多个窗口
QApplication a(argc, argv);
//创建空白窗口
QWidget w;
w.setWindowTitle("给杨妹妹的窗口");//设置标题
//创建按钮1
QPushButton b;
b.setText("杨的专属按钮");//给按钮设施内容
b.setParent(&w); //指定夫对象 此时显示在左上角 显示效果不好
//更改效果
b.move(100,100);//移动的是像素点
//创建按钮2
QPushButton b1(&w); //构造函数传参 指定父对象
b1.setText("abc");//给按钮设施内容
w.show();//给空间认为显示
/*如果不指定父对象 对象和对象(窗口和窗口)没有关系,是独立的
*a指定b为它的父对象 相当于a在b上(子在父上面)
*所以本案例需要指定窗口是父对象 按钮是子对象 有两种方式
* 1)setParent
* 2)构造函数传参
*指定父对象的好处,只需要父对象显示 上面那的子对象自动显示*/
return a.exec();
}
//创建按钮1
QPushButton b;
b.setText("杨的专属按钮");//给按钮设施内容
b.setParent(&w); //指定夫对象 此时显示在左上角 显示效果不好
//更改效果
b.move(100,100);//移动的是像素点
//创建按钮2
QPushButton b1(&w); //构造函数传参 指定父对象
b1.setText("abc");//给按钮设施内容
w.show();//给空间认为显示
/*如果不指定父对象 对象和对象(窗口和窗口)没有关系,是独立的
*a指定b为它的父对象 相当于a在b上(子在父上面)
*所以本案例需要指定窗口是父对象 按钮是子对象 有两种方式
* 1)setParent
* 2)构造函数传参
*指定父对象的好处,只需要父对象显示 上面那的子对象自动显示*/
return a.exec();
}

边栏推荐
- 小金额炒股,在手机上开户安全吗?
- 4、策略學習
- Transportation, new infrastructure and smart highway
- Application of state mode in JSF source code
- Know how to get the traffic password
- Cs5261type-c to HDMI alternative ag9310 | ag9310 alternative
- Common effects of line chart
- Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
- break net
- Recommend a document management tool Zotero | with tutorials and learning paths
猜你喜欢

2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination

How to use education discounts to open Apple Music members for 5 yuan / month and realize member sharing

break net

A speed Limited large file transmission tool for every major network disk

2. Nonlinear regression

4. Apprentissage stratégique

Redis集群

Talk about smart Park

2021 tea master (primary) examination materials and tea master (primary) simulation test questions

Kindle operation: transfer downloaded books and change book cover
随机推荐
Probability distribution
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
Basic realization of line chart (II)
Design method and application of ag9311maq and ag9311mcq in USB type-C docking station or converter
HDMI to VGA acquisition HD adapter scheme | HDMI to VGA 1080p audio and video converter scheme | cs5210 scheme design explanation
Gnuradio 3.9 using OOT custom module problem record
Markdown learning (entry level)
Matlab code on error analysis (MAE, MAPE, RMSE)
Cs5261type-c to HDMI alternative ag9310 | ag9310 alternative
2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
Use "recombined netlist" to automatically activate eco "APR netlist"
14. Draw network model structure
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
Cs5212an design display to VGA HD adapter products | display to VGA Hd 1080p adapter products
6. Dropout application
STM32GPIO口的工作原理
4. Cross entropy
Chapter 5 neural network
NPM Internal Split module
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small