代码练习
做一个UI登录页面
源文件
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);this->setWindowTitle("洛克启动!");this->setWindowIcon(QIcon(":/new/prefix1/picture/roco.jpg"));QMovie *mv = new QMovie(":/new/prefix1/picture/snow.gif");ui->showLab->setMovie(mv);mv->start();ui->headLab->setPixmap(QPixmap(":/new/prefix1/picture/roco.jpg"));ui->headLab->setScaledContents(true);ui->userEdit->setPlaceholderText("支持QQ号/邮箱/手机号登录");ui->paswdEdit->setPlaceholderText("请输入密码");ui->paswdEdit->setEchoMode(QLineEdit::Password);ui->logBtn->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px;color:white");}Widget::~Widget()
{delete ui;
}
头文件
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QMovie>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();signals:void my_signal();public slots:void my_slot();private:Ui::Widget *ui;
};
#endif // WIDGET_H
效果演示
登录页面演示