文章目录
- 创建项目
- 设置UI布局
- 控制数据库类实现
- 界面实现类
- 主函数
功能:用来管理数据库中图像资源
开发环境:windows10+VS2017+Qt5.14.2开发
创建项目
首先创建Qt Widgets Application
next->next->finish就创建好了
设置UI布局
打开已经创建好的UI控件,设计UI布局,根据自己需求可灵活修改,基本需要数据库的连接,图像资源导入、导出、预览、检索等。
控制数据库类实现
头文件:
#pragma once#include <QObject>
#include <QVariant>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <memory>#define ResourceDataSPtr std::shared_ptr<ControlDB::ResourceData>
#define ResourceDataList QVector<std::shared_ptr<ControlDB::ResourceData>>class ControlDB : public QObject
{Q_OBJECTpublic:enum PictureType{JPG,PNG,SVG};struct ResourceData{int id;QString name;QString svgContent;QByteArray pbgBuffer;PictureType picType;ResourceData(){id = 0;name = "";svgContent = "";}};// explicit 只能修饰含有一个参数的构造函数,或除第一个参数外其余参数都有默认值的构造函数。explicit ControlDB(QObject *parent = nullptr);~ControlDB(); // 连接sqlite数据库bool ConnectNewDatabase(const QString& _dbFilePath);// 查询所有图片资源ResourceDataList QueryPictureDataList();// 根据名称模糊查询图像数据ResourceDataList QueryPictureByName(const QString& _name);// 查询图片数据,需要从base64转回去// 二进制数据有不可见字符,传来传去容易数据错误,base64是可见字符ResourceDataSPtr QueryPicById(const int& _id);// 导入图片资源,资源名称-图片bufvoid ImportPicture(const QString& _resName, const QByteArray& _dataBuf, const PictureType& _type);// 更新图片数据void UpdatePicData(const int& _id, const QString& _newName, const QByteArray& _newData = "");// 根据ID删除图片数据void DeletePicById(const int& _id);// 查询所有svg资源ResourceDataList QuerySvgDataList();// 根据名字模糊查询svg数据ResourceDataList QuerySvgByName(const QString& _name);// 查询SVG图片数据ResourceDataSPtr QuerySvgById(const int& _id);// 导入svg资源void ImportSvg(const QString& _resName, const QString& _fileContent);// 更新SVG数据void UpdateSvgData(const int& _id, const QString& _newName, const QString& _fileContent = "");// 根据ID删除数据void DeleteSvgById(const int& _id);signals:private:QSqlDatabase* resDb_;};
源文件:
#include "ControlDB.h"#include <QDebug>
#include <QString>ControlDB::ControlDB(QObject *parent): QObject(parent), resDb_(nullptr)
{}ControlDB::~ControlDB()
{}bool ControlDB::ConnectNewDatabase(const QString& _dbFilePath)
{if (resDb_ != nullptr){resDb_->close();delete resDb_;resDb_ = nullptr;}// 其实账号密码没用resDb_ = new QSqlDatabase();*resDb_ = QSqlDatabase::addDatabase("QSQLITE");resDb_->setDatabaseName(_dbFilePath);//resDb_->setUserName("Luster");//resDb_->setPassword("123456");return resDb_->open();
}ResourceDataList ControlDB::QueryPictureDataList()
{ResourceDataList resDataList;QSqlQuery queryPic(*resDb_);queryPic.exec("SELECT * FROM PngData");while (queryPic.next()){ResourceDataSPtr curData = std::make_shared<ResourceData>();curData->id = queryPic.value("id").toInt();curData->name = queryPic.value("name").toString();curData->picType = (PictureType)queryPic.value("type").toInt();curData->pbgBuffer = QByteArray::fromBase64(queryPic.value("data").toByteArray());resDataList.push_back(curData);}return resDataList;
}ResourceDataList ControlDB::QueryPictureByName(const QString & _name)
{ResourceDataList resDataList;QSqlQuery queryPic(*resDb_);QString execSqlStr = QString("SELECT * FROM PngData WHERE name LIKE '%%1%'").arg(_name);queryPic.exec(execSqlStr);while (queryPic.next()){ResourceDataSPtr curData = std::make_shared<ResourceData>();curData->id = queryPic.value("id").toInt();curData->name = queryPic.value("name").toString();curData->picType = (PictureType)queryPic.value("type").toInt();curData->pbgBuffer = QByteArray::fromBase64(queryPic.value("data").toByteArray());resDataList.push_back(curData);}return resDataList;
}ResourceDataSPtr ControlDB::QueryPicById(const int& _id)
{ResourceDataSPtr resData = std::make_shared<ResourceData>();QSqlQuery queryPic(*resDb_);QString execSqlStr = QString("SELECT * FROM PngData WHERE id='%1'").arg(_id);queryPic.exec(execSqlStr);if (queryPic.next()){resData->id = queryPic.value("id").toInt();resData->name = queryPic.value("name").toString();resData->picType = (PictureType)queryPic.value("type").toInt();resData->pbgBuffer = queryPic.value("data").toByteArray();}return resData;
}void ControlDB::ImportPicture(const QString& _resName, const QByteArray& _dataBuf, const PictureType& _type)
{QSqlQuery queryPic(*resDb_);QByteArray base64Pic = _dataBuf.toBase64();QString insertSqlStr = QString("INSERT INTO PngData(name,type,data) values ('%1', '%2', '%3');").arg(_resName).arg(_type).arg(base64Pic.data());if (!queryPic.exec(insertSqlStr)){qDebug() << queryPic.lastError();}
}void ControlDB::UpdatePicData(const int& _id, const QString& _newName, const QByteArray& _newData /*= ""*/)
{QSqlQuery queryPic(*resDb_);QString UpdateSqlStr = "";if (_newData.isEmpty())UpdateSqlStr = QString("UPDATE PngData SET name='%1' WHERE id='%2'").arg(_newName).arg(_id);elseUpdateSqlStr = QString("UPDATE PngData SET name='%1',data='%2' WHERE id='%3'").arg(_newName).arg(_newData.toBase64().data()).arg(_id);if (!queryPic.exec(UpdateSqlStr)){qDebug() << queryPic.lastError();}
}void ControlDB::DeletePicById(const int& _id)
{QSqlQuery queryPic(*resDb_);QString insertSqlStr = QString("DELETE FROM PngData WHERE id='%1'").arg(_id);if (!queryPic.exec(insertSqlStr))qDebug() << queryPic.lastError();
}ResourceDataList ControlDB::QuerySvgDataList()
{ResourceDataList resDataList;QSqlQuery querySvg(*resDb_);querySvg.exec("SELECT * FROM SvgData");while (querySvg.next()){ResourceDataSPtr curData = std::make_shared<ResourceData>();curData->id = querySvg.value("id").toInt();curData->name = querySvg.value("name").toString();curData->svgContent = querySvg.value("data").toString();resDataList.push_back(curData);}return resDataList;
}ResourceDataList ControlDB::QuerySvgByName(const QString& _name)
{ResourceDataList resDataList;QSqlQuery querySvg(*resDb_);QString execSqlStr = QString("SELECT * FROM SvgData WHERE name LIKE '%%1%'").arg(_name);querySvg.exec(execSqlStr);while (querySvg.next()) {ResourceDataSPtr curData = std::make_shared<ResourceData>();curData->id = querySvg.value("id").toInt();curData->name = querySvg.value("name").toString();curData->svgContent = querySvg.value("data").toString();resDataList.push_back(curData);}return resDataList;
}ResourceDataSPtr ControlDB::QuerySvgById(const int& _id)
{ResourceDataSPtr resData = std::make_shared<ResourceData>();QSqlQuery querySvg(*resDb_);QString execSqlStr = QString("SELECT * FROM SvgData WHERE id='%1'").arg(_id);querySvg.exec(execSqlStr);if (querySvg.next()){resData->id = querySvg.value("id").toInt();resData->name = querySvg.value("name").toString();resData->svgContent = querySvg.value("data").toString();}return resData;
}void ControlDB::ImportSvg(const QString& _resName, const QString& _fileContent)
{QSqlQuery querySvg(*resDb_);QString insertSqlStr = QString("INSERT INTO SvgData (name,data) values ('%1','%2')").arg(_resName).arg(_fileContent);if (!querySvg.exec(insertSqlStr))qDebug() << querySvg.lastError();
}void ControlDB::UpdateSvgData(const int& _id, const QString& _newName, const QString& _fileContent /*= ""*/)
{QSqlQuery querySvg(*resDb_);QString insertSqlStr = "";if (_fileContent.isEmpty())insertSqlStr = QString("UPDATE SvgData SET name='%1' WHERE id='%2'").arg(_newName).arg(_id);elseinsertSqlStr = QString("UPDATE SvgData SET name='%1',data='%2' WHERE id='%3'").arg(_newName).arg(_fileContent).arg(_id);if (!querySvg.exec(insertSqlStr))qDebug() << querySvg.lastError();
}void ControlDB::DeleteSvgById(const int& _id)
{QSqlQuery querySvg(*resDb_);QString insertSqlStr = QString("DELETE FROM SvgData WHERE id='%1'").arg(_id);if (!querySvg.exec(insertSqlStr))qDebug() << querySvg.lastError();
}
界面实现类
头文件:
#pragma once#include <QtWidgets/QMainWindow>
#include "ui_DBTool.h"
#include "ControlDB.h"class DBTool : public QMainWindow
{Q_OBJECTpublic:DBTool (QWidget *parent = nullptr);~DBTool ();private slots:// 点击选择数据库文件void SlotSelectDbFile();// 连接数据库void SlotConnectResDb();// 导入资源文件,图片或者svgvoid SlotImportResource();// 表格里修改了资源的名字void SlotResourceNameChanged(QTableWidgetItem* _curItem);// 更新选中的资源图void SlotUpdateSelectResource();// 删除选中void SlotDeleteSelectRes();// 导出选中void SlotExportSelectRes();// 查询资源void SlotSearchResource(const QString& _curSearchName);private:Ui::DBToolClass ui;void InitUI();void InitSlots();// 刷新,从数据库查询图片数据下载void RefreshPngTable();// 查询svg数据显示void RefreshSvgTable();// 创建一个表格itemQTableWidgetItem* CreateTableItem(const QString& _text, const bool& _isReadOnly);// 设置操作数据库按钮状态 连接后可用void SetControlDbBtnEnable(bool _is_enable);// 导入图片 JPG和PNG 资源void ImportPng();// 导入svg资源void ImportSvg();// 获取选中的所有行号QVector<int> GetTableSelectRows();std::shared_ptr<ControlDB> control_db_Ptr_;
};
源文件:
#pragma execution-character_set("UTF-8")
#include "DBTool.h"
#include <QFileDialog>
#include <QHeaderView>
#include <QMessageBox>
#include <QLabel>
#include <QSvgWidget>
#include <QFileInfo>
#include <QDebug>DBTool::DBTool(QWidget *parent): QMainWindow(parent)
{ui.setupUi(this);setWindowTitle(QStringLiteral("资源管理器"));InitUI();InitSlots();
}DBTool::~DBTool()
{}void DBTool::SlotSelectDbFile()
{QString selectFilePath = QFileDialog::getOpenFileName(this, QStringLiteral("选择资源数据库"), "../../", "*.db");if (selectFilePath.isEmpty())return;ui.db_path_lineEdit->setText(selectFilePath);
}void DBTool::SlotConnectResDb()
{if (ui.db_path_lineEdit->text().isEmpty())return;bool connectDB = control_db_Ptr_->ConnectNewDatabase(ui.db_path_lineEdit->text());if (!connectDB){QMessageBox::critical(this, QStringLiteral("错误"), "数据库连接失败!");statusBar()->showMessage(QStringLiteral("错误:数据库连接失败!"));return;}elsestatusBar()->showMessage(QStringLiteral("提示:数据库连接成功!"));int curType = ui.type_comboBox->currentIndex();if (curType == 0)RefreshPngTable();else if (curType == 1)RefreshSvgTable();else{ }SetControlDbBtnEnable(true);
}void DBTool::SlotImportResource()
{if (ui.type_comboBox->currentIndex() == 0){ImportPng();RefreshPngTable();}else if (ui.type_comboBox->currentIndex() == 1){ImportSvg();RefreshSvgTable();}else{}
}void DBTool::SlotResourceNameChanged(QTableWidgetItem* _curItem)
{if (!_curItem)return;int changedRow = _curItem->row();if (!ui.db_data_tableWidget->item(changedRow, 0))return;if (!ui.db_data_tableWidget->item(changedRow, 2))return;int changedId = ui.db_data_tableWidget->item(changedRow, 0)->text().toInt();QString changedName = ui.db_data_tableWidget->item(changedRow, 2)->text();// 更新数据库数据if (ui.type_comboBox->currentIndex() == 0){// 更新图片数据control_db_Ptr_->UpdatePicData(changedId, changedName);}else if (ui.type_comboBox->currentIndex() == 1){// 更新SVG数据control_db_Ptr_->UpdateSvgData(changedId, changedName);}else{}qDebug() << changedId << changedName;QString changeText = QStringLiteral("更新资源ID:") + QString::number(changedId) + QStringLiteral("名称为") + changedName;statusBar()->showMessage(changeText);
}void DBTool::SlotUpdateSelectResource()
{// 只能选中一个更新QVector<int> selectRowList = GetTableSelectRows();if (selectRowList.size() != 1){QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("只能选择一行进行资源更新"));return;}int selectId = ui.db_data_tableWidget->item(selectRowList.first(), 0)->text().toInt();QString selectName = ui.db_data_tableWidget->item(selectRowList.first(), 2)->text();// 选择一个新的资源QString fileSuffix = ui.type_comboBox->currentIndex() == 0 ? "Images(*.jpg *.png *.JPG *.PNG)" : "*.svg";QString selectFilePath = QFileDialog::getOpenFileName(this, "选择资源文件", "../../", fileSuffix);if (selectFilePath.isEmpty())return;QFile picFile(selectFilePath);picFile.open(QIODevice::ReadOnly);QByteArray readBuf = picFile.readAll();QFileInfo picFileInfo(selectFilePath);if (ui.type_comboBox->currentIndex() == 0){control_db_Ptr_->UpdatePicData(selectId, picFileInfo.baseName(), readBuf);RefreshPngTable();}else{control_db_Ptr_->UpdateSvgData(selectId, picFileInfo.baseName(), readBuf);RefreshSvgTable();}picFile.close();
}void DBTool::SlotDeleteSelectRes()
{QVector<int> selectRowList = GetTableSelectRows();if (selectRowList.size() <= 0)return;for (const auto& curRow:selectRowList){int curId = ui.db_data_tableWidget->item(curRow, 0)->text().toInt();if (ui.type_comboBox->currentIndex() == 0)control_db_Ptr_->DeletePicById(curId);else if (ui.type_comboBox->currentIndex() == 1)control_db_Ptr_->DeleteSvgById(curId);}ui.type_comboBox->currentIndex() == 0 ? RefreshPngTable() : RefreshSvgTable();
}void DBTool::SlotExportSelectRes()
{QVector<int> selectRowList = GetTableSelectRows();if (selectRowList.size() == 0)return;QString savePath = QFileDialog::getExistingDirectory(this, "保存文件夹", "../../");if (savePath.isEmpty())return;for (const auto& curRow : selectRowList){int curId = ui.db_data_tableWidget->item(curRow, 0)->text().toInt();if (ui.type_comboBox->currentIndex() == 0){ResourceDataSPtr picBuffer = control_db_Ptr_->QueryPicById(curId);QFile saveFile(savePath + "/" + picBuffer->name + ".png");saveFile.open(QIODevice::WriteOnly);saveFile.write(QByteArray::fromBase64(picBuffer->pbgBuffer));saveFile.close();}else if (ui.type_comboBox->currentIndex() == 1){ResourceDataSPtr svgContent = control_db_Ptr_->QuerySvgById(curId);QFile saveFile(savePath + "/" + svgContent->name + ".svg");saveFile.open(QIODevice::WriteOnly);saveFile.write(svgContent->svgContent.toUtf8());saveFile.close();}}
}void DBTool::SlotSearchResource(const QString& _curSearchName)
{ResourceDataList queryRes;if (ui.type_comboBox->currentIndex() == 0){queryRes = control_db_Ptr_->QueryPictureByName(_curSearchName);ui.db_data_tableWidget->clearContents();ui.db_data_tableWidget->setRowCount(0);ui.db_data_tableWidget->setRowCount(queryRes.size());for (int i = 0; i < queryRes.size(); ++i){const auto& curSvgData = queryRes.at(i);ui.db_data_tableWidget->setItem(i, 0, CreateTableItem(QString::number(curSvgData->id), true));QLabel* bgWidget = new QLabel();QPixmap bgPix;bgPix.loadFromData(curSvgData->pbgBuffer);bgPix = bgPix.scaled(50, 50, Qt::KeepAspectRatio);bgWidget->setPixmap(bgPix);ui.db_data_tableWidget->setCellWidget(i, 1, bgWidget);ui.db_data_tableWidget->setItem(i, 2, CreateTableItem(curSvgData->name, false));ui.db_data_tableWidget->setItem(i, 3, CreateTableItem(curSvgData->picType == ControlDB::JPG ? "JPG" : "PNG", true));ui.db_data_tableWidget->setRowHeight(i, 50);}}else if (ui.type_comboBox->currentIndex() == 1){queryRes = control_db_Ptr_->QuerySvgByName(_curSearchName);ui.db_data_tableWidget->clearContents();ui.db_data_tableWidget->setRowCount(0);ui.db_data_tableWidget->setRowCount(queryRes.size());for (int i = 0; i < queryRes.size(); ++i){const auto& curSvgData = queryRes.at(i);ui.db_data_tableWidget->setItem(i, 0, CreateTableItem(QString::number(curSvgData->id), true));QSvgWidget* bgWidget = new QSvgWidget();bgWidget->load(curSvgData->svgContent.toUtf8());ui.db_data_tableWidget->setCellWidget(i, 1, bgWidget);ui.db_data_tableWidget->setItem(i, 2, CreateTableItem(curSvgData->name, false));ui.db_data_tableWidget->setItem(i, 3, CreateTableItem("SVG", true));}}
}void DBTool::InitUI()
{control_db_Ptr_ = std::make_shared<ControlDB>();SetControlDbBtnEnable(false);ui.db_path_lineEdit->setReadOnly(true);ui.search_lineEdit->setPlaceholderText(QStringLiteral("请输入查询资源名字"));ui.db_data_tableWidget->verticalHeader()->setHidden(false);ui.db_data_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);ui.db_data_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);QStringList resTableHeaderLabels;resTableHeaderLabels << "ID" << QStringLiteral("示例") << QStringLiteral("唯一名称") << QStringLiteral("类型");ui.db_data_tableWidget->setColumnCount(resTableHeaderLabels.size());ui.db_data_tableWidget->setHorizontalHeaderLabels(resTableHeaderLabels);
}void DBTool::InitSlots()
{connect(ui.chose_dbpath_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotSelectDbFile);connect(ui.connect_db_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotConnectResDb);connect(ui.type_comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [=](int _curIndex) {if (_curIndex == 0)RefreshPngTable();else if (_curIndex == 1)RefreshSvgTable();else{ }});connect(ui.import_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotImportResource);connect(ui.db_data_tableWidget, &QTableWidget::itemChanged, this, &LusterDBTool::SlotResourceNameChanged);connect(ui.update_select_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotUpdateSelectResource);connect(ui.delete_select_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotDeleteSelectRes);connect(ui.export_select_pushButton, &QPushButton::clicked, this, &LusterDBTool::SlotExportSelectRes);connect(ui.search_lineEdit, &QLineEdit::textChanged, this, &LusterDBTool::SlotSearchResource);
}void DBTool::RefreshPngTable()
{ui.db_data_tableWidget->blockSignals(true); //屏蔽掉信号,这样就不会触发itemChanged信号ui.db_data_tableWidget->clearContents();ui.db_data_tableWidget->setRowCount(0);ResourceDataList dataList = control_db_Ptr_->QueryPictureDataList();ui.db_data_tableWidget->setRowCount(dataList.size());for (int i=0;i<dataList.size();++i){const auto& curPngData = dataList.at(i);ui.db_data_tableWidget->setItem(i, 0, CreateTableItem(QString::number(curPngData->id), true));QLabel* bgWidget = new QLabel();QPixmap pngPix;pngPix.loadFromData(curPngData->pbgBuffer);pngPix = pngPix.scaled(50, 50, Qt::KeepAspectRatio);bgWidget->setPixmap(pngPix);ui.db_data_tableWidget->setCellWidget(i, 1, bgWidget);ui.db_data_tableWidget->setItem(i, 2, CreateTableItem(curPngData->name, false));ui.db_data_tableWidget->setItem(i, 3, CreateTableItem(curPngData->picType == ControlDB::JPG ? "JPG" : "PNG", true));ui.db_data_tableWidget->setRowHeight(i, 50);}ui.db_data_tableWidget->blockSignals(false);
}void DBTool::RefreshSvgTable()
{ui.db_data_tableWidget->blockSignals(true);ui.db_data_tableWidget->clearContents();ui.db_data_tableWidget->setRowCount(0);ResourceDataList dataList = control_db_Ptr_->QuerySvgDataList();ui.db_data_tableWidget->setRowCount(dataList.size());for (int i=0;i<dataList.size();++i){const auto curSvgData = dataList.at(i);ui.db_data_tableWidget->setItem(i, 0, CreateTableItem(QString::number(curSvgData->id), true));QSvgWidget* svgWidget = new QSvgWidget();svgWidget->setFixedSize(50, 50);svgWidget->load(curSvgData->svgContent.toUtf8());ui.db_data_tableWidget->setCellWidget(i, 1, svgWidget);ui.db_data_tableWidget->setItem(i, 2, CreateTableItem(curSvgData->name, false));ui.db_data_tableWidget->setItem(i, 3, CreateTableItem("SVG", true));ui.db_data_tableWidget->setRowHeight(i, 50);}ui.db_data_tableWidget->blockSignals(false);
}QTableWidgetItem* DBTool::CreateTableItem(const QString& _text, const bool& _isReadOnly)
{QTableWidgetItem* curItem = new QTableWidgetItem();curItem->setText(_text);curItem->setTextAlignment(Qt::AlignCenter);if (_isReadOnly)curItem->setFlags(Qt::ItemIsEnabled);return curItem;
}void DBTool::SetControlDbBtnEnable(bool _is_enable)
{ui.export_select_pushButton->setEnabled(_is_enable);ui.update_select_pushButton->setEnabled(_is_enable);ui.import_pushButton->setEnabled(_is_enable);ui.delete_select_pushButton->setEnabled(_is_enable);
}void DBTool::ImportPng()
{QStringList importFileList = QFileDialog::getOpenFileNames(this, "导入图片资源", "../../", "Images(*.jpg *.png *.JPG *.PNG)");if (importFileList.size() == 0)return;for (const auto& picFilePath:importFileList){QFile picFile(picFilePath);picFile.open(QIODevice::ReadOnly);QByteArray readBuf = picFile.readAll();QFileInfo picFileInfo(picFilePath);ControlDB::PictureType picType = picFileInfo.suffix().compare("png") == 0 ? ControlDB::PNG : ControlDB::JPG;control_db_Ptr_->ImportPicture(picFileInfo.baseName(), readBuf, picType);picFile.close();}statusBar()->showMessage(QStringLiteral("导入图像成功"));
}void DBTool::ImportSvg()
{QStringList importFileList = QFileDialog::getOpenFileNames(this, "导入SVG资源", "../../", "Images(*.svg)");if (importFileList.size() == 0)return;for (const auto& picFilePath:importFileList){QFile picFile(picFilePath);picFile.open(QIODevice::ReadOnly);QByteArray readBuf = picFile.readAll();QFileInfo picFileInfo(picFilePath);control_db_Ptr_->ImportSvg(picFileInfo.baseName(), readBuf);picFile.close();}
}QVector<int> DBTool::GetTableSelectRows()
{QVector<int> selectRowList;QList<QTableWidgetItem*> selectItemList = ui.db_data_tableWidget->selectedItems();for (const auto& selectItem : selectItemList){int curRow = selectItem->row();if(selectRowList.contains(curRow))continue;selectRowList.push_back(curRow);}return selectRowList;
}
主函数
#include "DBTool.h"
#include <QtWidgets/QApplication>int main(int argc, char *argv[])
{//system("chcp 65001");QApplication a(argc, argv);DBTool w;w.show();return a.exec();
}
源码链接:https://gitee.com/strange-tree-qian/qt-dbcontrol