#include "widget.h"
#include "ui_widget.h"
#include "QDebug"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->resize(QSize(800,600)); //使用匿名对象,调用重新设置尺寸函数
qDebug() << "size = " << this->size();
qDebug()<<"width = "<<this->width(); //输出组件宽度
qDebug()<<"height = "<<this->height(); //获取高度
//2、设置尺寸最值
this->setMaximumSize(1000,800); //设置最大尺寸
this->setMinimumSize(400,300); //设置最小尺寸
this->setFixedSize(500, 400); //设置固定尺寸
//3、窗口标题
qDebug()<<this->windowTitle();
this->setWindowTitle("鹏哥快聊");
qDebug()<<this->windowTitle();
//4、设置窗口的icon
this->setWindowIcon(QIcon("C:/Users/niyibo/Desktop/新建文件夹/wodepeizhenshi.png"));
QPushButton *btn1=new QPushButton(this);
btn1->setText("登录");
btn1->resize(QSize(70,35));
btn1->move(250,300);
btn1->setIcon(QIcon("C:/Users/niyibo/Desktop/新建文件夹/login.png"));
QPushButton *btn2=new QPushButton(this);
btn2->setText("取消");
btn2->resize(btn1->size());
btn2->move(btn1->x()+70,300);
btn2->setIcon(QIcon("C:/Users/niyibo/Desktop/新建文件夹/cancel.png"));
//1、构造一个行编辑器,构造时给定父组件
QLineEdit *edit1 = new QLineEdit(this);
edit1->setPlaceholderText("QQ/手机/邮箱"); //设置编辑器的占位文本
edit1->resize(200,40); //设置尺寸
edit1->move(btn1->x(),200); //移动位置
QLineEdit *edit2 = new QLineEdit(this);
edit2->setPlaceholderText("密码");//设置编辑器的占位文本
edit2->setEchoMode(QLineEdit::Password);
edit2->resize(200,40); //设置尺寸
edit2->move(btn1->x(),250); //移动位置
QLabel *tab1=new QLabel(this);
tab1->resize(500,200); //设置尺寸
tab1->move(0,0); //移动位置
tab1->setPixmap(QString("C:/Users/niyibo/Desktop/新建文件夹/logo.png"));
tab1->setScaledContents(true);
QLabel *tab2=new QLabel(this);
tab2->resize(40,40);
tab2->move(edit1->x()-50,200);
tab2->setPixmap(QString("C:/Users/niyibo/Desktop/新建文件夹/userName.jpg"));
tab2->setScaledContents(true);
QLabel *tab3=new QLabel(this);
tab3->resize(40,40);
tab3->move(edit2->x()-50,250);
tab3->setPixmap(QString("C:/Users/niyibo/Desktop/新建文件夹/passwd.jpg"));
tab3->setScaledContents(true);
}
Widget::~Widget()
{
delete ui;
}