QT day2

#include "widget.h"
#include "ui_widget.h"
#include
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lineEditUsr->setPlaceholderText("请输入用户名");
    ui->lineEditPassword->setPlaceholderText("请输入密码");
    ui->lineEditPassword->setEchoMode(QLineEdit::Password);
 
    connect(ui->lineEditPassword,SIGNAL(editingFinished() ) ,     
    this,SLOT(pbtnSubmitShow()));
    ui->rbtnEnter->setChecked(true);
    connect(ui->rbtnEnter,SIGNAL(clicked()), this, SLOT(rtbClickedSlotFun()));
    connect(ui->rbtnLogin,SIGNAL(clicked()), this, SLOT(rtbClickedSlotFun()));
    connect(ui->pbtnSubmit,SIGNAL(clicked()), this, SLOT(pbtnSubmitShow()));
}
 
Widget::~Widget()
{
    delete ui;
}
 
void Widget::rtbClickedSlotFun()
{
    if(ui->rbtnEnter->isChecked())
    {
        ui->pbtnSubmit->setText("登录");
    }
    else
    {
        ui->pbtnSubmit->setText("注册");
    }
}
 
void Widget::pbtnSubmitShow()
{
    QString str,str1;
    if(ui->rbtnEnter->isChecked())
    {
        str = "登录";
    }
    else
    {
        str="注册";
    }
   
    qDebug()<<"用户名:"<lineEditUsr->text()<<" 密码:"<lineEditPassword->text();
   
}

你可能感兴趣的:(命令模式)