当前位置:网站首页>QT使用sqllite
QT使用sqllite
2022-07-02 02:23:00 【NLeRnotfalled】
sql.pro目录里面,加入sql的支持
QT += core gui
QT += sql
为了防止生成到debug文件,需要在database名加入…/+“你的工程目录”/数据库名的运算符,使得.db文件生成在你的工程目录里
#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();
}
边栏推荐
- query词权重, 搜索词权重计算
- LFM signal denoising, time-frequency analysis, filtering
- Mathematics in Sinorgchem: computational geometry
- Which brand of running headphones is good? How many professional running headphones are recommended
- CVPR 2022 | Dalian Institute of technology proposes a self calibration lighting framework for low light level image enhancement of real scenes
- Start from scratch - Web Host - 01
- A quick understanding of analog electricity
- Additional: information desensitization;
- Es interview questions
- 离婚3年以发现尚未分割的共同财产,还可以要么
猜你喜欢

Leetcode face T10 (1-9) array, ByteDance interview sharing
![[opencv] - comprehensive examples of five image filters](/img/c7/aec9f2e03a17c22030d7813dd47c48.png)
[opencv] - comprehensive examples of five image filters

leetcode2312. Selling wood blocks (difficult, weekly race)

query词权重, 搜索词权重计算
![[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table](/img/f4/298f64c4b4f8674eda4e8fb19a976a.png)
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table

AR增强现实可应用的场景

A quick understanding of analog electricity

Design and implementation of key value storage engine based on LSM tree
![[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)](/img/8e/a86a9724251718d98ce172a6a96e53.png)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
![[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology](/img/2d/299fa5c76416f74bd1a693c433dd09.png)
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
随机推荐
研发中台拆分过程的一些心得总结
[opencv] - comprehensive examples of five image filters
Software development life cycle -- waterfall model
Pytest testing framework
pytest 测试框架
[graduation season] graduate seniors share how to make undergraduate more meaningful
剑指 Offer 62. 圆圈中最后剩下的数字
软件开发生命周期 --瀑布模型
query词权重, 搜索词权重计算
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
A quick understanding of analog electricity
How to run oddish successfully from 0?
Deep learning: a solution to over fitting in deep neural networks
附加:信息脱敏;
Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
Oracle creates a user with read-only permission in four simple steps
剑指 Offer 47. 礼物的最大价值
Summary of some experiences in the process of R & D platform splitting
[punch in questions] integrated daily 5-question sharing (phase II)
【做题打卡】集成每日5题分享(第二期)