qt第二天

#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
    edit1=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();
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值