胡恩全10.15作业
1.思维导图
2.登录界面
MyWidget::MyWidget(QWidget *parent): QWidget(parent)
{//首先设置界面大小以及界面美化this->resize(640,480);this->setWindowTitle("登录吧..."); //标题this->setWindowIcon(QIcon("D:\\picture\\logo.png")); //图标this->setStyleSheet("background-color:rgb(100,100,100)"); //背景色this->setFixedSize(640,480); //固定大小//创建一个标签QLabel *lab = new QLabel(this);lab->resize(320,480); //标签大小//设置动态图片QMovie *mv = new QMovie("D:\\picture\\mysearch.gif");lab->setMovie(mv);mv->start();lab->setScaledContents(true); //大小自适应//创建用户名和密码标签QLabel *uname = new QLabel(this);QLabel *pwd = new QLabel(this);uname->resize(60,40); //大小pwd->resize(60,40);//标签设置为图片uname->setPixmap(QPixmap("D:\\picture\\userName.jpg"));pwd->setPixmap(QPixmap("D:\\picture\\passwd.jpg"));uname->setScaledContents(true); //大小自适应pwd->setScaledContents(true);uname->move(330,60); //移动pwd->move(330,120);//创建行编辑器QLineEdit *edit1 = new QLineEdit(this);QLineEdit *edit2 = new QLineEdit(this);edit1->resize(230,40); //大小edit2->resize(230,40);//设置回显格式 edit1为默认Normaledit2->setEchoMode(QLineEdit::Password); //密文显示edit1->setPlaceholderText("请输入用户名..."); //设置占位edit2->setPlaceholderText("请输入密码...");edit1->setStyleSheet("color:white"); //字体颜色edit2->setStyleSheet("color:white");edit1->move(400,60); //移动edit2->move(400,120);//创建登录按钮 注册按钮QPushButton *btn1 = new QPushButton("登录",this);QPushButton *btn2 = new QPushButton("注册",this);btn1->resize(100,60); //大小btn2->resize(100,60);//设置按钮背景色格式 倒角 字体颜色btn1->setStyleSheet("background-color:blue;border-radius:5px;color:yellow");btn2->setStyleSheet("background-color:blue;border-radius:5px;color:yellow");btn1->move(370,400); //移动btn2->move(490,400);//创建标签 用于美化QLabel *lab1 =new QLabel(this);lab1->resize(320,150);QMovie *mv1 = new QMovie("D:\\picture\\mys.gif");lab1->setMovie(mv1);mv1->start();lab1->move(320,205);lab1->setScaledContents(true);QLabel *lab2 = new QLabel(this);lab2->resize(200,35);lab2->setText("欢迎您的登录!");lab2->setStyleSheet("color:white");lab2->move(420,360);
}