当前位置:网站首页>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();
}
边栏推荐
- leetcode2305. Fair distribution of biscuits (medium, weekly, shaped pressure DP)
- Iterative unified writing method of binary tree
- leetcode373. 查找和最小的 K 对数字(中等)
- RTL8189FS如何关闭Debug信息
- How to run oddish successfully from 0?
- [C #] use regular verification content
- 使用开源项目【Banner】实现轮播图效果(带小圆点)
- If you want to rewind the video picture, what simple methods can you use?
- Word search applet design report based on cloud development +ppt+ project source code + demonstration video
- Flutter un élément au milieu, l'élément le plus à droite
猜你喜欢

From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years

If you want to rewind the video picture, what simple methods can you use?

How to solve MySQL master-slave delay problem

Redis环境搭建和使用的方法

Sword finger offer 62 The last remaining number in the circle

Types of exhibition items available in the multimedia interactive exhibition hall

How to use redis ordered collection

A quick understanding of digital electricity
![[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)

Software development life cycle -- waterfall model
随机推荐
Medical management system (C language course for freshmen)
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
leetcode2312. 卖木头块(困难,周赛)
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
flutter 中间一个元素,最右边一个元素
花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)
Deployment practice and problem solving of dash application development environment based on jupyter Lab
2022安全员-C证考试题及模拟考试
flutter 中間一個元素,最右邊一個元素
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
实现一个自定义布局的扫码功能
Es interview questions
Ar Augmented Reality applicable scenarios
Opengauss database backup and recovery guide
使用开源项目【Banner】实现轮播图效果(带小圆点)
Start from scratch - Web Host - 01
[reading notes] programmer training manual - practical learning is the most effective (project driven)
C # use system data. The split mixed mode assembly is generated for the "v2.0.50727" version of the runtime, and it cannot be loaded in the 4.0 runtime without configuring other information
leetcode2305. 公平分发饼干(中等,周赛,状压dp)