Qt建立按钮

先在头文件中包含要引用的头文件
在类中定义成员数据和成员函数
#include<QPushButton>
private:
QPushButton *button;
在源文件中使用button
1.创建QPushButton控件
button = new QPushButton(this);
2.给控件付属性 一般付属性都用->
button->setGeometry(QRect(50,50,100,25));
button->setText("按钮");
3.连接信号与槽
connect(button,SIGNAL(clicked(bool)),this,SLOT(showMainwindow2()));

posted @ 2016-02-01 20:28  空想代码中  阅读(5959)  评论(0编辑  收藏  举报