Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of QT accessing QSqlite database

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The QtSql module provides an interface to access the SQL database independent of the platform and database type, which is supported by a set of classes that integrate the database and the user interface using the model view structure of Qt.

The QSqlDatabase object symbolizes the association of the database. Qt uses drivers to communicate with the API of various databases. The desktop version of Qt (Desktop Edition) includes the following drivers:

Driver database

QDB2 IBM DB2 version 7.1 and newer version

QIBASE Borland InterBase

QMYSQL MySql

QOCI Oracle (Oracle Call Interface)

QODBC ODBC (including Microsoft's QSL service)

Version 7.3 and later of QPSQL PostgreSQL

QSQLITE QSLite version 3

QSQLITE2 QSLite version 2

QTDS Qybase adaptive server

Access to an example of QSqlite database: step: 1. Create a Qt console program. 2. Add QT + = sql;3 to the pro inquiry and the following code to the main.cpp:

[cpp] view plain copy print?

# include

# include

# include

# include

# include

# include

# include

# include

# include

Int main (int argc, char * argv [])

{

QCoreApplication a (argc, argv)

QSqlDatabase database = QSqlDatabase::addDatabase ("QSQLITE")

Database.setDatabaseName ("CashSystem.db")

If (database.open ())

{

QDebug ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report