![QT第一天_第1张图片](http://img.e-com-net.com/image/info8/c9979d2b10f24c80849fb7258e2703f1.jpg)
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
qDebug("%s","hello world"); //输出函数 qDebug()
qDebug() << "ni hao";
qDebug() << "size = " << this->size(); //输出组件大小
this->resize(QSize(540,410)); //重新设置尺寸
qDebug() << "size = " << this->size();
qDebug() << "width = " << this->width(); //获取宽度
qDebug() << "height = " << this->height(); //获取高度
this->setFixedSize(540,410);//设置固定尺寸
//窗口标题
qDebug() << this->windowTitle();
this->setWindowTitle("QQ");
qDebug() << this->windowTitle();
//设置窗口的图标
this->setWindowIcon(QIcon("C:/Users/Administrator/Desktop/qq.png"));
//设置背景色,一般使用样式表完成
// this->setStyleSheet("background-color:skyblue;");
//设置透明度
this->setWindowOpacity(1);
//设置纯净窗口
// this->setWindowFlag(Qt::FramelessWindowHint);
//移动窗口位置
// this->move(50,100);
//构造一个按钮
QPushButton *btn1 =new QPushButton;
btn1->setParent(this);
btn1->setText("登录"); //给组件设置文本内容
btn1->resize(QSize(200,40)); //设置按钮组件的大小
btn1->move(190,350);
btn1->setStyleSheet("background-color:skyblue;" //设置样式表
"border-radius:10px;"
"color:white;");
btn1->setIcon(QIcon("C:/Users/Administrator/Desktop/3.png"));
QPushButton *btn2 = new QPushButton("注册账号",this);
btn2->resize(80,30);
btn2->move(0,380);
QPushButton *btn3 = new QPushButton("找回密码",this);
btn3->resize(90,30);
btn3->move(340,310);
//1.构造一个行编辑器
QLineEdit *edit1=new QLineEdit(this);
// edit1->setText(""); //设置编辑器文本中的内容
edit1->setPlaceholderText("qq/手机/邮箱"); //设置编辑器的占位文本
edit1->resize(300,40);
edit1->move(140,200);
QLineEdit *edit2=new QLineEdit(this);
// edit1->setText(""); //设置编辑器文本中的内容
edit2->setPlaceholderText("密码"); //设置编辑器的占位文本
edit2->resize(300,40);
edit2->move(140,260);
edit2->setEchoMode(QLineEdit::Password);
//实例化一个标签
QLabel *lab1= new QLabel("账户",this);
lab1->resize(40,40);
lab1->move(100,200);
// lab1->setStyleSheet("background-color:yellow");
lab1->setPixmap(QPixmap("C:/Users/Administrator/Desktop/1.png"));
lab1->setScaledContents(true); //设置内容自适应
QLabel *lab2= new QLabel("密码",this);
lab2->resize(40,40);
lab2->move(100,260);
lab2->setPixmap(QPixmap("C:/Users/Administrator/Desktop/2.png"));
lab2->setScaledContents(true); //设置内容自适应
QLabel *lab3= new QLabel(this);
lab3->resize(540,190);
lab3->setPixmap(QPixmap("C:/Users/Administrator/Desktop/4.png"));
lab3->setScaledContents(true); //设置内容自适应
QCheckBox *cb1=new QCheckBox("记住密码",this);
cb1->resize(90,40);
cb1->move(140,300);
QCheckBox *cb2=new QCheckBox("自动登录",this);
cb2->resize(90,40);
cb2->move(230,300);
}