widget.h
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QIcon> //图标类
#include <QPushButton>
#include <QLineEdit> //行编辑
#include <QLabel>
#include <QTextEdit>
#include <QMovie>class Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();
};
#endif // WIDGET_H
widge.c
#include "widget.h"Widget::Widget(QWidget *parent): QWidget(parent)
{this -> setWindowTitle("CC");this -> setWindowIcon(QIcon("D:/图片/Camera Roll/QQ图片20211106093913.jpg"));this -> setStyleSheet("background-color : rgb(194,228,255)");this -> setWindowOpacity(0.9);this -> resize(540,410);this -> setFixedSize(540,410);// this -> setWindowFlag(Qt::FramelessWindowHint, 1);// this -> setWindowFlag(Qt::WindowFullscreenButtonHint , 0);//插入水印QLabel *lab1 = new QLabel(this);lab1-> resize(500, 300);lab1-> move(185, 120);lab1-> setPixmap(QPixmap("D:/图片/Camera Roll/风呤(1)(1).png"));lab1-> setScaledContents(true);//插图动图QLabel *gif = new QLabel(this);gif -> resize(540, 155);gif -> setStyleSheet("background-color:writh");QMovie *mv = new QMovie("D:/图片/hutao.webp");gif -> setMovie(mv);mv -> start();gif -> setScaledContents(true);//设置按钮QPushButton *btn1 = new QPushButton;btn1 -> setParent(this);btn1 -> setText("登录");btn1 -> setStyleSheet("background-color : rgb(80,2,250);color:white;border-radius:5px");btn1 -> resize(240,40);btn1 -> move(115, 300);QPushButton *btn2 = new QPushButton("注册", this);
// btn2 -> setParent(this);
// btn2 -> setText("注册");btn2 -> setStyleSheet("background-color : rgb(99,29,250)");btn2 -> resize(60,40);btn2 -> move(15, 360);QPushButton *btn3 = new QPushButton(QIcon("D:/图片/Camera Roll/QQ图片20211106093913.jpg"), "帮助", this);btn3 -> resize(60,40);btn3 -> move(460, 360);btn3 -> setEnabled(0);//行编辑器QLineEdit *edit = new QLineEdit;//行编辑器的占位edit -> setPlaceholderText("CC账号");edit -> setParent(this);edit -> move(155,196);edit -> resize(200,40);edit -> setEchoMode(QLineEdit::Normal);QLineEdit *edit2 = new QLineEdit;edit2 -> setPlaceholderText("CC密码");edit2-> setParent(this);edit2 -> move(155,250);edit2 -> resize(200,40);edit2 -> setEchoMode(QLineEdit::Password);//插入图片QLabel *lab = new QLabel(this);lab -> resize(40, 30);lab -> move(110, 200);lab -> setPixmap(QPixmap("D:/图片/卿本墨唧.png"));lab -> setScaledContents(true);QLabel *lock = new QLabel(this);lock -> resize(35, 35);lock -> move(115, 250);lock -> setPixmap(QPixmap("D:/图片/passwd.png"));lock -> setScaledContents(true);}Widget::~Widget()
{}
main.c
#include "widget.h"#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.show();return a.exec();
}
胡桃