#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
//窗口
this->resize(640,800);
this->setStyleSheet("background-color:#fff;"
// "border:3px dashed #40E0D0;"
//"margin:3px solid #4169E1;"
"background-image:transparent"
);
this->setWindowFlag(Qt::FramelessWindowHint);
/*******************************************************************/
//label
QLabel *lab1=new QLabel(this);
lab1->resize(60,60);
lab1->setPixmap(QPixmap("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/qq.png"));
lab1->move(15,15);
lab1->setScaledContents(true);
QLabel *lab2=new QLabel(this);
lab2->resize(80,60);
lab2->move(90,15);
lab2->setText("QQ");
lab2->setStyleSheet("color:#000");
QFont font1("times new roman",30);
// font1.setBold(true);
lab2->setFont(font1);
// 令logo有由小变大的动画
QLabel *lab3=new QLabel(this);
lab3->resize(640,360);
lab3->setPixmap(QPixmap("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/logo.png"));
lab3->move(0,90);
lab3->setScaledContents(true);
// 创建动画并设置动画属性
QPropertyAnimation *animation = new QPropertyAnimation(lab3, "geometry");
animation->setDuration(1000); // 设置动画的时间长度(毫秒)
animation->setStartValue(QRect(0,90, 160,90)); // 设置动画的起始大小
animation->setEndValue(QRect(0,90, 640, 360)); // 设置动画的结束大小
// 启动动画
animation->start();
//用户图标
QLabel *lab4=new QLabel(this);
lab4->resize(60,60);
lab4->setPixmap(QPixmap("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/userName.jpg"));
lab4->move(120,480);
lab4->setScaledContents(true);
//密码图标
QLabel *lab5=new QLabel(this);
lab5->resize(60,60);
lab5->setPixmap(QPixmap("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/passwd.jpg"));
lab5->move(120,570);
lab5->setScaledContents(true);
//lineEdit
QLineEdit *edit1=new QLineEdit(this);
edit1->resize(300,60);
edit1->move(210,480);
edit1->setPlaceholderText("QQ号码/手机/邮箱");
edit1->setStyleSheet("background-color:url(C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/manc.jpeg)");
QLineEdit *edit2=new QLineEdit("密码",this);
edit2->resize(edit1->size());
edit2->move(210,570);
qDebug()<<edit2->text();
edit2->setEchoMode(QLineEdit::Password);
//pushbutton
QPushButton *btn1=new QPushButton;
btn1->setParent(this);
btn1->setText("登录");
btn1->resize(100,40);
btn1->move(320,660);
QIcon icon1("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/login.png");
btn1->setIcon(icon1);
QSize iconSize1(30,30);
btn1->setIconSize(iconSize1);
btn1->setStyleSheet("text-align:left;"
"color:black;"
"border:3px solid #bfcde4;"
"background-color:white");
QPushButton *btn2=new QPushButton;
btn2->setParent(this);
btn2->setText("取消");
btn2->resize(btn1->size());
btn2->move(450,660);
QIcon icon2("C:/Users/Administrator/Desktop/华清培训课程及衍生/QT/icon/cancel.png");
btn2->setIcon(icon2);
btn2->setIconSize(iconSize1);
btn2->setStyleSheet("text-align:left;"
"color:black;"
"border:3px solid #bfcde4;"
"background-color:white");
}
Widget::~Widget()
{
}
QT——Day1
最新推荐文章于 2024-06-16 22:23:43 发布