TestWidget.h

#ifndef __DEMO_TEST_WIDGET_H__
#define __DEMO_TEST_WIDGET_H__

class OfficeContainer;

class DemoTestWidget: public QWidget
{
    Q_OBJECT
public:
    DemoTestWidget(QWidget *parent = NULL);
    ~DemoTestWidget();

private slots:
    void sltBtnOpen();
    void sltBtnSelect();
    void sltBtnClose();
    void sltBtnShowDlg();

private:
    void initUI();
    void initConnect();

    QLabel          *pLblPath;
    QLineEdit       *pTxtPath;
    QPushButton     *pBtnOpen;
    QPushButton     *pBtnSelect;
    QPushButton     *pBtnClose;
    QComboBox       *pComBox;
    QPushButton     *pBtnShowDlg;

    QWidget         *pCentrelWgt;

    OfficeContainer *pOfficeContainer;
};


#endif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include "widget.h" #include "ui_widget.h" #include <QSqlQuery> //操作数据库 #include <QDebug> //输出错误信息 #include <QSqlError> // #include <QMessageBox> //#include <TestWidget3.h> //跳转窗口头文件 #include <QCheckBox> Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::on_regButton_clicked() { //密码 //插入数据 QSqlQuery query; query.prepare("INSERT INTO userinfo(account,password) VALUES (':value1', ':value2')"); query.bindValue(":value1",ui->accountEdit->text() ); query.bindValue(":value2",ui->passwordedit->text()); if(query.exec()){ //如果插入数据成功 QMessageBox::information(this,"注册","注册成功"); }else{ QMessageBox::information(this,"注册","注册失败"); } } void Widget::on_loginButton_clicked() { //接收用户输入 QSqlQuery query; //操作数据库 query.prepare("select * from user where account = ':value1' and password= ':value2'"); query.bindValue(":value1", ui->accountEdit->text()); query.bindValue(":value2", ui->passwordedit->text()); if(!query.exec()){ //如果没有查到记录 QMessageBox::information(this,"登录","登录失败"); } //获取查询的数据: if(query.next()){ //获取到数据 QMessageBox::information(this,"登录","登录成功"); }else{ QMessageBox::information(this,"登录","登录失败"); } } 这段代码用于实现用户注册与登录功能,但运行时总是注册失败,登录失败,请帮我修改这段代码,修复bug
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值