• 大小: 17.58MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-19
  • 语言: 数据库
  • 标签: qt  

资源简介

基于qt5.6.2 sqlite 界面优美 功能完美 数据库可用sqliteStudio打开编辑 放在工具类中

资源截图

代码片段和文件信息

#include “adminmanager.h“
#include “ui_adminmanager.h“
#include“qdebug.h“
#include“QTableView“
#include 
#include 
#include 
#include 
#include“QSqlQuery“
#include“teacherdialog.h“
#include“coursedialog.h“
#include“roomdialog.h“
#include“mainwindow.h“
adminManager::adminManager(QWidget *parent) :
    QMainWindow(parent)
    ui(new Ui::adminManager)
{
    ui->setupUi(this);
}

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

void adminManager::on_comboBox_currentIndexChanged(int index)
{
    if(index==0)
    {
        QStandardItemModel *model = new QStandardItemModel();
        model->setColumnCount(3);
            model->setHeaderData(0Qt::Horizontaltr(“工号“));
             model->setHeaderData(1Qt::Horizontaltr(“姓名“));
              model->setHeaderData(2Qt::Horizontaltr(“课程编号“));

            ui->stu_tableview->setModel(model);
            QSqlQuery *sqlQuery = new QSqlQuery;
            QString sqlStr = “select * from teacher“;
            sqlQuery->prepare( sqlStr );
            bool flag=sqlQuery->exec();


            int i=0;
            if(flag)
            {


               //读取查询到的记录
                qDebug()<ject::tr(“flag =true“);
               while( sqlQuery->next() )
               {

                  model->setItem( i 0 new QStandardItem( sqlQuery->value(0).toString()));
                  model->setItem( i 1 new QStandardItem( sqlQuery->value(1).toString()));
                    model->setItem( i 2 new QStandardItem( sqlQuery->value(2).toString()));

                    i++;
               }
               //ui->stu_tableview->setModel(model);



    }//if
    }//if(index)

    if(index==1)
    {
        QStandardItemModel *model = new QStandardItemModel();
        model->setColumnCount(3);
            model->setHeaderData(0Qt::Horizontaltr(“课程编号“));
             model->setHeaderData(1Qt::Horizontaltr(“课程名“));
              model->setHeaderData(2Qt::Horizontaltr(“学分“));

            ui->stu_tableview->setModel(model);
            QSqlQuery *sqlQuery = new QSqlQuery;
            QString sqlStr = “select * from course“;
            sqlQuery->prepare( sqlStr );
            bool flag=sqlQuery->exec();


            int i=0;
            if(flag)
            {


               //读取查询到的记录
                qDebug()<ject::tr(“flag =true“);
               while( sqlQuery->next() )
               {

                  model->setItem( i 0 new QStandardItem( sqlQuery->value(0).toString()));
                  model->setItem( i 1 new QStandardItem( sqlQuery->value(1).toString()));
                    model->setItem( i 2 new QStandardItem( sqlQuery->value(2).toString()));

                    i++;
               }
               //ui->stu_tableview->setModel(model);



    }//if

    }//if(index==1)
    if(index==2){

        QStand

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-06-12 19:22  teacaherManager\
     目录           0  2017-06-12 19:22  teacaherManager\teacherManager\
     文件        4560  2017-06-11 23:19  teacaherManager\teacherManager\adminmanager.cpp
     文件         555  2017-06-11 23:19  teacaherManager\teacherManager\adminmanager.h
     文件        3084  2017-06-11 23:19  teacaherManager\teacherManager\adminmanager.ui
     文件       20480  2017-06-11 09:10  teacaherManager\teacherManager\aehyok.db
     文件       30813  2011-05-27 09:29  teacaherManager\teacherManager\back.jpg
     文件        1367  2017-06-11 21:12  teacaherManager\teacherManager\coursedialog.cpp
     文件         410  2017-06-11 21:08  teacaherManager\teacherManager\coursedialog.h
     文件        2784  2017-06-11 21:08  teacaherManager\teacherManager\coursedialog.ui
     文件         518  2017-06-09 11:18  teacaherManager\teacherManager\dbconnection.cpp
     文件         334  2017-06-09 11:00  teacaherManager\teacherManager\dbconnection.h
     文件      359178  2017-05-31 16:35  teacaherManager\teacherManager\kk.gif
     文件        2663  2017-06-11 22:30  teacaherManager\teacherManager\login.cpp
     文件         532  2017-06-11 22:30  teacaherManager\teacherManager\login.h
     文件        2742  2017-06-11 22:30  teacaherManager\teacherManager\login.ui
     文件         214  2017-06-11 10:05  teacaherManager\teacherManager\main.cpp
     文件        1176  2017-06-12 07:22  teacaherManager\teacherManager\mainwindow.cpp
     文件         533  2017-06-12 07:28  teacaherManager\teacherManager\mainwindow.h
     文件        2877  2017-06-12 07:28  teacaherManager\teacherManager\mainwindow.ui
     文件      198191  2017-06-11 18:04  teacaherManager\teacherManager\purl.jpg
     文件        6783  2017-06-12 08:31  teacaherManager\teacherManager\query.cpp
     文件         430  2017-06-12 08:18  teacaherManager\teacherManager\query.h
     文件        2716  2017-06-12 08:18  teacaherManager\teacherManager\query.ui
     文件        1311  2017-06-11 22:38  teacaherManager\teacherManager\registerdialog.cpp
     文件         425  2017-06-11 22:38  teacaherManager\teacherManager\registerdialog.h
     文件        2269  2017-06-11 22:34  teacaherManager\teacherManager\registerdialog.ui
     文件         158  2017-06-11 18:08  teacaherManager\teacherManager\resourcefile.qrc
     文件        1245  2017-06-11 21:25  teacaherManager\teacherManager\roomdialog.cpp
     文件         394  2017-06-11 21:23  teacaherManager\teacherManager\roomdialog.h
     文件        2287  2017-06-11 21:19  teacaherManager\teacherManager\roomdialog.ui
............此处省略78个文件信息

评论

共有 条评论