赞
踩
#include "widget.h" #include "ui_widget.h" //#include <QPushButton> Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); ui->picture->setPixmap(QPixmap("C:\\Users\\Li Jie\\Desktop\\tupian.bmp"));//设置背景图片 ui->picture->setScaledContents(true);//图片自适应 setWindowFlag(Qt::FramelessWindowHint,true);//去掉标题栏 ui->lineEdit_passwd->setEchoMode(QLineEdit::Password);//密码模式 //启用关闭按钮 connect(ui->btn_close, SIGNAL(clicked()), this, SLOT(close())); //禁用关闭按钮功能 connect(ui->btn_disable_close, SIGNAL(clicked()), this, SLOT(slot_disable_close())); //登录按钮 connect(ui->btn_login, &QPushButton::clicked, this, &Widget::slot_login); } Widget::~Widget() { delete ui; } //禁用按钮槽函数 void Widget::slot_disable_close() { disconnect(ui->btn_close, SIGNAL(clicked()), this, SLOT(close())); ui->label_state->setText("禁用关闭按钮成功"); } //登录按钮槽函数 void Widget::slot_login() { if(ui->lineEdit_userName->text() == "admin" && ui->lineEdit_passwd->text() == "123456") { ui->label_state->setText("登录成功"); close(); }else { ui->label_state->setText("登录失败"); ui->lineEdit_passwd->clear(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。