当前位置:网站首页>写一个纯手写的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();
}

边栏推荐
- Redis cluster
- C# ?,?.,?? .....
- 5. Over fitting, dropout, regularization
- 11. Recurrent neural network RNN
- 2、TD+Learning
- Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
- Redis集群
- Led serial communication
- About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
- The difference between distribution function and probability density function of random variables
猜你喜欢

2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination

break net

2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills

3、多智能体强化学习

Recommend a document management tool mendely Reference Manager

Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board

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

2. Nonlinear regression

Understanding of maximum likelihood estimation

Micro rabbit gets a field of API interface JSON
随机推荐
2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
14. Draw network model structure
Leetcode notes No.21
Ag7120 and ag7220 explain the driving scheme of HDMI signal extension amplifier | ag7120 and ag7220 design HDMI signal extension amplifier circuit reference
解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
小金额炒股,在手机上开户安全吗?
2021 welder (primary) examination skills and welder (primary) operation examination question bank
Kaptcha generates verification code on Web page
2、TD+Learning
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
2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
5、离散控制与连续控制
5. Contrôle discret et contrôle continu
The difference between distribution function and probability density function of random variables
Chapter 16 intensive learning
6. Dropout application
AttributeError: ‘str‘ object has no attribute ‘strftime‘
3、多智能体强化学习
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds