#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
,btn1(new QPushButton(this))
{
ui->setupUi(this);
btn1->resize(ui->btn2->width(),ui->btn2->height());
//移动登录的位置
btn1->move(ui->btn2->x(),ui->btn2->y()+90);
btn1->setText("登录");
btn1->setStyleSheet("font-size:16px;font-family:'黑体'");
connect(btn1,SIGNAL(clicked()),this,SLOT(my_slots()));
//创建显示和隐藏按钮
ui->showbtn->setIcon(QIcon(":/new/prefix1/pictrue/biyan.png"));
ui->showbtn->setCheckable(true);
ui->showbtn->setStyleSheet("background-color:rgb(255,255,255);%50;border:none");
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_btn2_clicked()
{
this->close();
}
void Widget::my_slots()
{
QString a=ui->account->text();
QString b=ui->password->text();
if(a=="admin"&&b=="123456")
{
ui->xianshi->setText("登录成功");
QTimer::singleShot(1000, this, SLOT(close()));
}
else
{
ui->xianshi->setText("登录失败");
ui->password->setText(" ");
}
}
void Widget::on_showbtn_clicked()
{
if(ui->showbtn->isChecked())
{
ui->password->setEchoMode(QLineEdit::Normal);
ui->showbtn->setIcon(QIcon(":/new/prefix1/pictrue/kaiyan.png"));
}
else{
ui->password->setEchoMode(QLineEdit::Password);
ui->showbtn->setIcon(QIcon(":/new/prefix1/pictrue/biyan.png"));
}
}
6.14啊啊啊啊啊
最新推荐文章于 2024-11-04 10:42:34 发布