• 大小: 12KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: C/C++
  • 标签: Qt  C++  

资源简介

基于Qt的C++小项目,主要场景为报账系统。

资源截图

代码片段和文件信息

#include “account.h“
#include “ui_account.h“
#include 
#include 
#include 
#include 
const int NUMBER_PARAMETER = 18;
Account::Account(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::Account)
{
    ui->setupUi(this);
    this->model = new Db_model();
    this->ui->tbv_budget->setModel(this->model->tv_model);
}

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

void Account::on_le_detail_editingFinished()
{
    //init the pro_spc
    return;
}

void Account::on_pushButton_clicked()
{
    // if some line edits are not cmpleted
    if(this->ui->le_detail->text().isEmpty() || this->ui->le_money->text().isEmpty() || this->ui->le_name->text().isEmpty() || this->ui->le_person->text().isEmpty()){
        QMessageBox msgBox;
        msgBox.setText(“请输入全部信息“);
        msgBox.exec();
        return;
    }
    // already exist so display the information and enable some line edit
    if(this->model->select_sigle_project(this->ui->le_name->text())){
        this->ui->de_start_time->setTime(QTime::fromString(this->model->pro_spc.at(1)));
        this->ui->de_end_time->setTime(QTime::fromString(this->model->pro_spc.at(2)));
        this->ui->de_start_time->setEnabled(false);
        this->ui->de_end_time->setEnabled(false);
    }
    else{
        this->ui->de_start_time->setEnabled(true);
        this->ui->de_end_time->setEnabled(true);
    }
    // use the input of ui to updata the pro_spc
    for(int i=0; i        this->model->pro_spc.append(QString::number(i));
    this->model->pro_spc.replace(0 this->ui->le_name->text());
    this->model->pro_spc.replace(1 this->ui->de_start_time->text());
    this->model->pro_spc.replace(2 this->ui->de_end_time->text());
    this->model->update_db(this->ui->le_money->text() this->ui->cbb_rb_type->currentIndex()
                           this->ui->le_detail->text());
}

void Account::on_btn_cancel_clicked()
{
    this->close();
}

void Account::on_le_name_editingFinished()
{
    //the project has existed unable some le
    if(this->model->select_sigle_project(this->ui->le_name->text())){
        this->ui->de_start_time->setTime(QTime::fromString(this->model->pro_spc.at(1)));
        this->ui->de_end_time->setTime(QTime::fromString(this->model->pro_spc.at(2)));
        this->ui->de_start_time->setEnabled(false);
        this->ui->de_end_time->setEnabled(false);
    }
    else{
        this->model->tv_model->clear();
        this->model->set_tv_model_head();
        this->ui->de_start_time->setEnabled(true);
        this->ui->de_end_time->setEnabled(true);
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2693  2018-09-27 15:25  Qt_Homework\account.cpp

     文件        527  2018-09-27 15:25  Qt_Homework\account.h

     文件       6509  2018-09-27 15:25  Qt_Homework\account.ui

     文件       7981  2018-09-27 15:25  Qt_Homework\db_model.cpp

     文件       1340  2018-09-27 15:25  Qt_Homework\db_model.h

     文件       1213  2018-09-27 15:25  Qt_Homework\HomeWork.pro

     文件     207379  2018-09-27 15:25  Qt_Homework\HomeWork.pro.user

     文件        228  2018-09-27 15:25  Qt_Homework\main.cpp

     文件        903  2018-09-27 15:25  Qt_Homework\mainwindow.cpp

     文件        481  2018-09-27 15:25  Qt_Homework\mainwindow.h

     文件       5196  2018-09-27 15:25  Qt_Homework\mainwindow.ui

     文件        899  2018-09-27 15:25  Qt_Homework\query.cpp

     文件        399  2018-09-27 15:25  Qt_Homework\query.h

     文件       4111  2018-09-27 15:25  Qt_Homework\query.ui

    ..AD...         0  2018-09-27 19:49  Qt_Homework

----------- ---------  ---------- -----  ----

               239859                    15


评论

共有 条评论