数据库

    QSqlQuery query;
    QString zhanghao="\""+ui->lineEdit_3->text()+"\"";
    QString mima="\""+ui->lineEdit_4->text()+"\"";
    QString str=QString("insert into denglu(name,password)values(%1,%2)").arg(zhanghao).arg(mima);
    query.exec(str);
 
 
    a=ui->eat->text().toFloat();
    b=ui->others->text().toFloat();
    sum=a+b;
    QSqlQuery query;
    QString sql = QString("insert into money(id,date,eat,others,sum) values('',now(),%1,%2,%3)").arg(a).arg(b).arg(sum);
    query.exec(sql);
    //将变量a,b,sum的值插入到数据库中
 

你可能感兴趣的:(数据库)