当前位置:网站首页>QT uses sqllite
QT uses sqllite
2022-07-02 02:28:00 【NLeRnotfalled】
sql.pro Inside the directory , Join in sql Support for
QT += core gui
QT += sql
To prevent generation to debug file , Need to be in database Join in …/+“ Your project catalog ”/ Operator of database name , bring .db The file is generated in your project directory
#include "mainwindow.h"
#include <QApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("../sql/test.db");
db.open();
QString path = QCoreApplication::applicationDirPath();
qDebug()<<path;
QSqlQuery query;
query.exec("CREATE TABLE student(id INT PRIMARY KEY, username VARCHAR(30),pwd VARCHAR(30))");
MainWindow w;
w.show();
qDebug()<<QSqlDatabase::drivers();
return a.exec();
}
边栏推荐
- OpenCASCADE7.6编译
- Ar Augmented Reality applicable scenarios
- 附加:信息脱敏;
- RTL8189FS如何关闭Debug信息
- 【OpenCV】-5种图像滤波的综合示例
- How to use redis ordered collection
- Leetcode face T10 (1-9) array, ByteDance interview sharing
- 【带你学c带你飞】2day 第8章 指针(练习8.1 密码开锁)
- The wave of layoffs in big factories continues, but I, who was born in both non undergraduate schools, turned against the wind and entered Alibaba
- es面試題
猜你喜欢
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
How to hide the scroll bar of scroll view in uniapp
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
How to batch add background and transition effects to videos?
If you want to rewind the video picture, what simple methods can you use?
leetcode2312. 卖木头块(困难,周赛)
What kind of good and cost-effective Bluetooth sports headset to buy
How does MySQL solve the problem of not releasing space after deleting a large amount of data
Cesium dynamic diffusion point effect
随机推荐
Design and implementation of key value storage engine based on LSM tree
【OpenCV】-5种图像滤波的综合示例
Webgpu (I): basic concepts
golang---锁
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
essay structure
Ar Augmented Reality applicable scenarios
LFM signal denoising, time-frequency analysis, filtering
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
剑指 Offer 47. 礼物的最大价值
Architecture evolution from MVC to DDD
DNS domain name resolution
2022 low voltage electrician test question simulation test question bank simulation test platform operation
As a software testing engineer, will you choose the bank post? Laolao bank test post
flutter 中间一个元素,最右边一个元素
Sword finger offer II 031 Least recently used cache
How to hide the scroll bar of scroll view in uniapp
【毕业季】研究生学长分享怎样让本科更有意义
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
An analysis of circuit for quick understanding