QT周四作业

题目:

QT周四作业_第1张图片

代码:
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lineEditName->setPlaceholderText("请输入用户名");
    ui->lineEditPasswd->setPlaceholderText("请输入密码");
    ui->lineEditPasswd->setEchoMode(QLineEdit::Password);
    ui->loginushButton->setText("登录");
    ui->loginRadioButton->setChecked(true);
    connect(ui->loginushButton,SIGNAL(clicked()),this,SLOT(loginBtnClickFun()));
    connect(ui->loginRadioButton,SIGNAL(clicked()),this,SLOT(clickRadioBtnFun()));
    connect(ui->registerRadioButton_2,SIGNAL(clicked()),this,SLOT(clickRadioBtnFun()));
    connect(ui->lineEditPasswd,SIGNAL(editingFinished()),this,SLOT(loginBtnClickFun()));

}

Widget::~Widget()
{
    delete ui;
}

void Widget::loginBtnClickFun()
{
    qDebug()<<"name = "<lineEditName->text()<<"passwd = "<lineEditPasswd->text();
    ui->loginushButton->isChecked()?qDebug()<<"loginRadioButton isChecked":qDebug()<<"registerRadioButton isChecked";
    ui->checkBox->isChecked()?qDebug()<<"checkBox isChecked":qDebug()<<"checkBox isNotChecked";

}

void Widget::clickRadioBtnFun()
{
    if(ui->loginRadioButton->isChecked())
    {
        ui->loginushButton->setText("登录");
    }

    if(ui->registerRadioButton_2->isChecked())
    {
        ui->loginushButton->setText("注册");

    }

}

widget.h
#ifndef WIDGET_H
#define WIDGET_H

#include 

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

public slots:
    void loginBtnClickFun();
    void clickRadioBtnFun();
private:
    Ui::Widget *ui;
};
#endif // WIDGET_H

QT周四作业_第2张图片

你可能感兴趣的:(qt,命令模式,开发语言)