widget.cpp文件代码:
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{qDebug()<<this->size();qDebug()<<this->frameSize();this->setFixedSize(500,700);//设置标题this->setWindowTitle("League of Legends启动器");qDebug()<<this->windowTitle();//设置窗口图标this->setWindowIcon(QIcon("C:\\Users\\24148\\Desktop\\01\\game.png"));//更改背景颜色this->setStyleSheet("background-color:#FFEBCD;");//设置窗口透明度//this->setWindowOpacity(0.9);/*********************************************///设置logoQLabel *lab1 = new QLabel(this);lab1->setStyleSheet("background-color:#FFEBCD;");lab1->resize(500,300);lab1->setPixmap(QPixmap("C:\\Users\\24148\\Desktop\\01\\log.svg"));//自适应lab1->setScaledContents(true);//账户图标QLabel *lab2 = new QLabel(this);lab2->resize(50,50);lab2->setPixmap(QPixmap("C:\\Users\\24148\\Desktop\\01\\login.svg"));lab2->move(100,330);//自适应lab2->setScaledContents(true);//密码图标QLabel *lab3 = new QLabel(this);lab3->resize(50,50);lab3->setPixmap(QPixmap("C:\\Users\\24148\\Desktop\\01\\passwd.svg"));lab3->move(100,430);//自适应lab3->setScaledContents(true);/*********************************************//*********************************************///设置行输入//账号QLineEdit *edit1 = new QLineEdit(this);edit1->resize(240,50);edit1->move(200,330);edit1->setStyleSheet("border:none;");edit1->setPlaceholderText("QQ号/手机号/邮箱");//设置字体大小edit1->setFont(QFont("宋体",15));//密码QLineEdit *edit2 = new QLineEdit(this);edit2->resize(edit1->size());edit2->move(200,430);//获取 文本框内容qDebug()<<edit2->text();//将文本内容设置密文模式edit2->setEchoMode(QLineEdit::Password);edit2->setPlaceholderText("密码");//设置字体大小edit2->setFont(QFont("宋体",15));edit2->setStyleSheet("border:none;");/*********************************************//*********************************************///按键//登录QPushButton *btn1 = new QPushButton(QIcon("C:\\Users\\24148\\Desktop\\01\\login_button.svg"),"登录",this);btn1->resize(100,50);btn1->move(200,530);btn1->setFont(QFont("宋体",15));//登出QPushButton *btn2 = new QPushButton(QIcon("C:\\Users\\24148\\Desktop\\01\\no.svg"),"取消",this);btn2->resize(100,50);btn2->move(200,600);btn2->setFont(QFont("宋体",15));}Widget::~Widget()
{}
widget.h文件
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QWidget>
#include <QDebug>
#include <QIcon>
#include <QButtonGroup>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>namespace Ui {
class Widget;
}class Widget : public QWidget
{Q_OBJECTpublic:explicit Widget(QWidget *parent = nullptr);~Widget();private:Ui::Widget *ui;
};#endif // WIDGET_H