?一、手動(dòng)實(shí)現(xiàn)登錄框
源碼:
widge.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QDebug> //用于打印輸出
#include <QIcon> //圖標(biāo)頭文件
#include <QPushButton> //按鈕類頭文件
#include <QLineEdit> //行編輯器類
#include <QLabel> //標(biāo)簽文件
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
//標(biāo)簽類
QLabel *lab1;
QLabel *lab2;
QLabel *lab3;
//行編輯器類
QLineEdit *edit1;
QLineEdit *edit2;
//按鈕類
QPushButton *btn1;
QPushButton *btn2;
};
#endif // WIDGET_H
?widge.cpp
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
//設(shè)置整體大小、標(biāo)題及圖標(biāo)
this->setFixedSize(700, 600);
this->setWindowTitle("IKUN真愛小屋?");
this->setWindowIcon(QIcon("F:\\23051C++QT\\QT Day1\\test\\1.jpeg"));
this->setWindowOpacity(0.95); //設(shè)置透明度
//設(shè)置Logo標(biāo)簽
lab1 = new QLabel(this);
lab1->resize(700,200);
lab1->setPixmap(QPixmap("F:\\23051C++QT\\QT Day1\\test\\2.JPG"));
lab1->setScaledContents(true); //設(shè)置內(nèi)容自適應(yīng)
//設(shè)置用戶和密碼所圖標(biāo)
lab2 = new QLabel(this);
lab2->resize(50,50);
lab2->setPixmap(QPixmap("F:\\23051C++QT\\QT Day1\\test\\username.png"));
lab2->setScaledContents(true);
lab2->move(150,260);
lab3 = new QLabel(this);
lab3->resize(50,50);
lab3->setPixmap(QPixmap("F:\\23051C++QT\\QT Day1\\test\\passwd.jpg"));
lab3->setScaledContents(true);
lab3->move(150,360);
//設(shè)置行編輯器
edit1 = new QLineEdit(this);
edit1->resize(190, 40);
edit1->move(280, 265);
edit1->setStyleSheet("border : none; "
"border-bottom: 2px solid grey;");
edit1->setPlaceholderText("賬號:");
edit2 = new QLineEdit(this);
edit2->resize(190, 40);
edit2->move(280, 365);
edit2->setStyleSheet("border : none; "
"border-bottom: 2px solid grey;");
edit2->setPlaceholderText("密碼:");
edit2->setEchoMode(QLineEdit::Password);
//設(shè)置按鈕
btn1 = new QPushButton(this);
btn1->setText("登錄");
btn1->resize(130,40);
btn1->move(150, 490);
btn1->setIcon(QIcon("F:\\23051C++QT\\QT Day1\\test\\login.png"));
btn2 = new QPushButton(this);
btn2->setText("取消");
btn2->resize(130,40);
btn2->move(440, 490);
btn2->setIcon(QIcon("F:\\23051C++QT\\QT Day1\\test\\cancel.png"));
}
Widget::~Widget()
{
}
?main.cpp文章來源:http://www.zghlxwxcb.cn/news/detail-606282.html
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
二、思維導(dǎo)圖:
文章來源地址http://www.zghlxwxcb.cn/news/detail-606282.html
到了這里,關(guān)于嵌入式:QT Day1的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!