#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
{// 设置窗口大小this->resize(window_width, window_heigth);// 固定窗口大小this->setFixedSize(window_width, window_heigth);// 设置窗口图标this->setWindowIcon(QIcon("E:/code/pictrue/qq.png"));// 设置窗口背景颜色this->setStyleSheet("background-color:rgb(255,255,255)");// 设置上半部分样式QLabel *up_bg = new QLabel(this);up_bg->resize(530,150);//设置label大小QMovie *mv_bg = new QMovie("E:\\code\\pictrue\\login-bg.gif");//设置背景图片up_bg->setScaledContents(true);//设置图片按比例缩放up_bg->setMovie(mv_bg);//把动图添加到label容器中mv_bg->start();//让动图动起来// 设置中间的头像图片QLabel *avater = new QLabel(this);avater->setPixmap(QPixmap("E:\\code\\pictrue\\login.png"));avater->resize(88,88);avater->move(220,100);//移动label到坐标系x220,y100avater->setScaledContents(true);// 下半部分登录// 用户名lableQLabel *username_icon = new QLabel(this);username_icon->setPixmap(QPixmap("E:\\code\\pictrue\\user-icon.png"));username_icon->resize(17,17);username_icon->move(115,218);username_icon->setScaledContents(true);
// 创建用户名行编辑器QLineEdit *user = new QLineEdit(this);user->setPlaceholderText("请输入账号");user->move(138,208);user->resize(296,32);
// 创建密码 lableQLabel *paswd_icon = new QLabel(this);paswd_icon->setPixmap(QPixmap("E:\\code\\pictrue\\lock-icon.png"));//为label添加图片paswd_icon->resize(17,17);paswd_icon->move(115,260);paswd_icon->setScaledContents(true);
// 创建密码行编辑器QLineEdit *paswd = new QLineEdit(this);paswd->setPlaceholderText("请输入密码");//设置行编辑器占位符paswd->setEchoMode(QLineEdit::Password);//设置显示模式是密码paswd->resize(296,32);paswd->move(138,254);
// 创建登录按钮QPushButton *login_btn = new QPushButton("登录",this);//初始话按钮,按钮文字是登录login_btn->resize(296,36);login_btn->setStyleSheet("background-color:rgb(7,188,252)");//设置背景颜色login_btn->move(130,350);
}MainWindow::~MainWindow()
{
}
qt初试