Commit 5f2b295d authored by Qiu Chuntao's avatar Qiu Chuntao

Add new file

parent bd6a768f
#include "regist.h"
#include "ui_regist.h"
Regist::Regist(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Regist)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose,1);
}
Regist::~Regist()
{
delete ui;
}
void Regist::getdata(QSqlDatabase db1,QString tablename1) {
db = db1;
tablename = tablename1;
}
void Regist::on_pushButton_clicked()
{
QString username = ui->usrname->text();
QString password = ui->psw->text();
QString sql = QString("insert into user(username,password) "
"values('%1',%2);").arg(username).arg(password);
qDebug() << sql;
QSqlQuery sql_query(db);
if(!sql_query.exec(sql))
{
qDebug() << "注册失败" << sql_query.lastError();
return;
}
qDebug()<< "注册成功";
}
void Regist::on_goback_clicked()
{
this->parentWidget()->show();
this->close();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment