QT——QPushbutton类

代码图

狗杂QPushbutton类

1.创建QPushbutton:QPushButton b;

2.构造按钮为父窗口的子类QPushButton b(&w);

使用和解释

1.设置按钮显示内容:b.setText("^_^");

2.显示按钮:b.show();

3.指定按钮为主window的子类:(控件默认隐藏,需要人为显示b.show(),按钮需要指定父对象,按钮也是一个窗口)

指定父对象的方法:①setParent②通过构造函数传参,指定父对象后,父对象show后子对象自动显示。设置父对象:①b.setParent(&w) ② QPushButton b(&w);

4.设置按钮移动到指定坐标