题目:
文章来源:https://www.toymoban.com/news/detail-812425.html
代码:
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
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 = "<<ui->lineEditName->text()<<"passwd = "<<ui->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 <QWidget>
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
文章来源地址https://www.toymoban.com/news/detail-812425.html
到了这里,关于QT周四作业的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!