赞
踩
- #ifndef WIDGET_H
- #define WIDGET_H
-
- #include <QWidget>
- #include <QDebug> //用于打印输出
- #include <QIcon> //图标头文件
- #include <QPushButton> //按钮类头文件
- #include <QLineEdit> //行编辑器类
- #include <QLabel> //标签文件
-
- class Widget : public QWidget
- {
- Q_OBJECT
-
- public:
- Widget(QWidget *parent = nullptr);
- ~Widget();
-
- //标签类
- QLabel *lab1;
- QLabel *lab2;
- QLabel *lab3;
-
- //行编辑器类
- QLineEdit *edit1;
- QLineEdit *edit2;
-
- //按钮类
- QPushButton *btn1;
- QPushButton *btn2;
-
- };
- #endif // WIDGET_H
- #include "widget.h"
-
- Widget::Widget(QWidget *parent)
- : QWidget(parent)
- {
- //设置整体大小、标题及图标
- this->setFixedSize(700, 600);
- this->setWindowTitle("IKUN真爱小屋❤");
- this->setWindowIcon(QIcon("F:\\23051C++QT\\QT Day1\\test\\1.jpeg"));
- this->setWindowOpacity(0.95); //设置透明度
-
- //设置Logo标签
- lab1 = new QLabel(this);
- lab1->resize(700,200);
- lab1->setPixmap(QPixmap("F:\\23051C++QT\\QT Day1\\test\\2.JPG"));
- lab1->setScaledContents(true); //设置内容自适应
-
- //设置用户和密码所图标
- 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);
-
- //设置行编辑器
- 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);
-
- //设置按钮
- 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()
- {
- }
-
- #include "widget.h"
-
- #include <QApplication>
-
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- Widget w;
- w.show();
- return a.exec();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。