widget.cpp文件代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-540605.html
#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);
//設(shè)置標題
this->setWindowTitle("League of Legends啟動器");
qDebug()<<this->windowTitle();
//設(shè)置窗口圖標
this->setWindowIcon(QIcon("C:\\Users\\24148\\Desktop\\01\\game.png"));
//更改背景顏色
this->setStyleSheet("background-color:#FFEBCD;");
//設(shè)置窗口透明度
//this->setWindowOpacity(0.9);
/*********************************************/
//設(shè)置logo
QLabel *lab1 = new QLabel(this);
lab1->setStyleSheet("background-color:#FFEBCD;");
lab1->resize(500,300);
lab1->setPixmap(QPixmap("C:\\Users\\24148\\Desktop\\01\\log.svg"));
//自適應(yīng)
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);
//自適應(yīng)
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);
//自適應(yīng)
lab3->setScaledContents(true);
/*********************************************/
/*********************************************/
//設(shè)置行輸入
//賬號
QLineEdit *edit1 = new QLineEdit(this);
edit1->resize(240,50);
edit1->move(200,330);
edit1->setStyleSheet("border:none;");
edit1->setPlaceholderText("QQ號/手機號/郵箱");
//設(shè)置字體大小
edit1->setFont(QFont("宋體",15));
//密碼
QLineEdit *edit2 = new QLineEdit(this);
edit2->resize(edit1->size());
edit2->move(200,430);
//獲取 文本框內(nèi)容
qDebug()<<edit2->text();
//將文本內(nèi)容設(shè)置密文模式
edit2->setEchoMode(QLineEdit::Password);
edit2->setPlaceholderText("密碼");
//設(shè)置字體大小
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文件文章來源地址http://www.zghlxwxcb.cn/news/detail-540605.html
#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_OBJECT
public:
explicit Widget(QWidget *parent = nullptr);
~Widget();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
到了這里,關(guān)于QT day1簡單登錄界面的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!