#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
// qDebug()<<this->size(); // 输出默认尺寸 QSize(800, 600)
//this->resize(QSize(800,800)); // 改变尺寸 (800,800)
this->setWindowTitle("原批聚集地"); //设置窗口标题
//设置窗口图标
this->setWindowIcon(QIcon("D:/cqt/day1/icon/yuanpi.png"));
//设置背景颜色
// this->setStyleSheet("background-color:black;");
//设置窗口透明度
this->setWindowOpacity(0.9);
//按钮
//定义一个按钮,构造时给点图标,文本,父组件
b1 = new QPushButton(QIcon("D:/cqt/day1/icon/login.png"),"btn1",this);
b2 = new QPushButton(QIcon("D:/cqt/day1/icon/cancel.png"),"btn2",this);
//设置大小
this->b1->resize(80,80);
this->b2->resize(80,80);
//移动到指定位置
b1->move(600,500);
b2->move(700,500);
//标签
//
l1=new QLabel(this);
l2=new QLabel(this);
l3=new QLabel(this);
//设置图片
l1->setPixmap(QPixmap("D:/cqt/day1/icon/logo.png"));
l2->setPixmap(QPixmap("D:/cqt/day1/icon/userName.jpg"));
l3->setPixmap(QPixmap("D:/cqt/day1/icon/passwd.jpg"));
//设置标签大小
l1->resize(800,300);
l2->resize(50,50);
l3->resize(50,50);
//设置图片适应标签大小
l1->setScaledContents(true);
l2->setScaledContents(true);
l3->setScaledContents(true);
//移动标签
l2->move(150,350);
l3->move(150,450);
//行编辑器
le1 = new QLineEdit(this);
le2 = new QLineEdit(this);
//移动
le1->move(230,360);
le2->move(230,460);
//设置密文模式
le2->setEchoMode(QLineEdit::Password);
//le2->setPlaceholderText("密码");
}
Widget::~Widget()
{
delete ui;
}
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
//头文件
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QDebug>
#include <QIcon>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
private:
Ui::Widget *ui;
//两个按钮
QPushButton *b1;
QPushButton *b2;
//标签
QLabel *l1;
QLabel *l2;
QLabel *l3;
//编辑器
QLineEdit *le1;
QLineEdit *le2;
};
#endif // WIDGET_H