1.QQ登錄界面
頭文件代碼
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QMovie>
#include <QLineEdit>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
~MyWidget();
};
#endif // MYWIDGET_H
main代碼
#include "mywidget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();
return a.exec();
}
源代碼
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
//=====================窗口類=======================
//設(shè)置窗口標(biāo)題
this->setWindowTitle("QQ");
//設(shè)置窗口圖標(biāo)
this->setWindowIcon(QIcon("D:\\QT\\23101\\QT\\picture\\qq2_logo.png"));
//設(shè)置窗口大小
this->resize(430,330);
//固定窗口大小
this->setFixedSize(430,330);
//設(shè)置顏色
this->setStyleSheet("background-color:rgb(255,255,255)");
//設(shè)置純凈窗口
this->setWindowFlag(Qt::FramelessWindowHint);
//==================標(biāo)簽類=========================
//設(shè)置標(biāo)簽1
QLabel *background = new QLabel(this);
//設(shè)置標(biāo)簽大小
background->resize(430,127);
//設(shè)置動(dòng)圖類
QMovie *mv = new QMovie("D:\\QT\\23101\\QT\\picture\\qq2.gif");
//將動(dòng)圖插入到標(biāo)簽中
background->setMovie(mv);
//啟動(dòng)動(dòng)圖
mv->start();
//設(shè)置動(dòng)圖自動(dòng)適應(yīng)大小
background->setScaledContents(true);
//設(shè)置標(biāo)簽2
QLabel *lab1 = new QLabel(this);
//設(shè)置標(biāo)簽位置
lab1->move(15,12);
//設(shè)置大小
lab1->resize(65,32);
//設(shè)置透明度
lab1->setStyleSheet("background-color:transparent");
//插入圖片
lab1->setPixmap(QPixmap("D:\\QT\\23101\\QT\\picture\\qq_logo.png"));
//設(shè)置圖片自動(dòng)適應(yīng)大小
lab1->setScaledContents(true);
//設(shè)置標(biāo)簽3
QLabel *lab2 = new QLabel(this);
//設(shè)置標(biāo)簽位置
lab2->move(99,175);
//設(shè)置標(biāo)簽大小
lab2->resize(22,26);
//插入圖片
lab2->setPixmap(QPixmap("D:\\QT\\23101\\QT\\picture\\qq3.png"));
//設(shè)置自動(dòng)適應(yīng)大小
lab2->setScaledContents(true);
//設(shè)置標(biāo)簽4
QLabel *lab3 = new QLabel(this);
//設(shè)置標(biāo)簽位置
lab3->move(97,203);
//設(shè)置標(biāo)簽大小
lab3->resize(23,27);
//插入圖片
lab3->setPixmap(QPixmap("D:\\QT\\23101\\QT\\picture\\passwd.png"));
//設(shè)置自動(dòng)適應(yīng)大小
lab3->setScaledContents(true);
//=======================行編輯器類============================
//設(shè)置行編輯器1賬號(hào)
QLineEdit *edit1 = new QLineEdit(this);
//設(shè)置行編輯器大小
edit1->resize(200,27);
//設(shè)置行編輯器位置
edit1->move(122,175);
//設(shè)置占位
edit1->setPlaceholderText("QQ號(hào)碼/手機(jī)/郵箱");
//設(shè)置行編輯器2密碼
QLineEdit *edit2 = new QLineEdit(this);
//設(shè)置行編輯器大小
edit2->resize(200,27);
//設(shè)置行編輯器位置
edit2->move(122,203);
//設(shè)置占位
edit2->setPlaceholderText("密碼");
//設(shè)置密碼輸入模式
edit1->setEchoMode(QLineEdit::Password);
//============================按鈕類=============================
//設(shè)置按鈕1
QPushButton *btn1 = new QPushButton("登錄",this);
//設(shè)置按鈕背景顏色
btn1->setStyleSheet("background-color:rgb(31,199,253);color:white;border-radius:5px");
//設(shè)置大小
btn1->resize(235,35);
//移動(dòng)位置
btn1->move(97,275);
?2.思維導(dǎo)圖文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-811866.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-811866.html
到了這里,關(guān)于QT DAY1作業(yè)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!