当前位置:网站首页>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();
}
边栏推荐
- 大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
- 2022低压电工考试题模拟考试题库模拟考试平台操作
- Medical management system (C language course for freshmen)
- 研发中台拆分过程的一些心得总结
- LFM signal denoising, time-frequency analysis, filtering
- [punch in questions] integrated daily 5-question sharing (phase II)
- [opencv] - comprehensive examples of five image filters
- LeetCode刷题(十)——顺序刷题46至50
- [pit] how to understand "parameter fishing"
- What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
猜你喜欢

MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent

超图iServer rest服务之feature查询

Vsocde has cli every time it is opened js

MySQL主从延迟问题怎么解决

LFM信号加噪、时频分析、滤波

MySQL中一条SQL是怎么执行的

leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)

How to run oddish successfully from 0?

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

LFM signal denoising, time-frequency analysis, filtering
随机推荐
Start from scratch - Web Host - 01
Which brand of running headphones is good? How many professional running headphones are recommended
How to batch add background and transition effects to videos?
研发中台拆分过程的一些心得总结
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
Which kind of sports headphones is easier to use? The most recommended sports headphones
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
Opengauss database backup and recovery guide
Golang lock
How to turn off debug information in rtl8189fs
leetcode2312. 卖木头块(困难,周赛)
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
Which brand of sports headset is better? Bluetooth headset suitable for sports
【毕业季】研究生学长分享怎样让本科更有意义
【深度学习】infomap 人脸聚类 facecluster
SQL server calculates the daily average and annual average of the whole province
Comparative analysis of MVC, MVP and MVVM, source code analysis
Sword finger offer 47 Maximum value of gifts
trading
Divorce for 3 years to discover the undivided joint property, or