#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、设置窗口的iconedit1=new QLineEdit(this);edit2=new QLineEdit(this);this->setWindowIcon(QIcon("C:/Users/Desktop/新建文件夹/wodepeizhenshi.png"));QPushButton *btn1=new QPushButton(this);btn1->setText("登录");btn1->resize(QSize(70,35));btn1->move(250,300);btn1->setIcon(QIcon("C:/Users/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/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/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/Desktop/新建文件夹/passwd.jpg"));tab3->setScaledContents(true);connect(btn1,&QPushButton::clicked,this,&Widget::loginBtn_slot);
}Widget::~Widget()
{delete ui;
}
void Widget::loginBtn_slot()
{QString userName=this->edit1->text();QString pwd=this->edit2->text();if(userName=="admin"&&pwd=="123456"){qDebug()<<"登录成功";emit jump();this->close();}else{qDebug()<<"登录失败";}
}
void Widget::on_jumpBtn_clicked()
{emit jump(); //发射跳转信号this->close();
}