Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_sql_kernel_qsqldriver.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QSqlDatabase>
4#include <QSqlQuery>
5#include <QSqlDriver>
6#include <QVariant>
7
9{
10//dummy definitions
11typedef void sqlite3;
12typedef void PGconn;
13typedef void MYSQL;
14//! [0]
15QSqlDatabase db = QSqlDatabase::database();
16QVariant v = db.driver()->handle();
17if (v.isValid() && (qstrcmp(v.typeName(), "sqlite3*") == 0)) {
18 // v.data() returns a pointer to the handle
19 sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
20 if (handle) {
21 // ...
22 }
23}
24//! [0]
25
26//! [1]
27if (qstrcmp(v.typeName(), "PGconn*") == 0) {
28 PGconn *handle = *static_cast<PGconn **>(v.data());
29 if (handle) {
30 // ...
31 }
32}
33
34if (qstrcmp(v.typeName(), "MYSQL*") == 0) {
35 MYSQL *handle = *static_cast<MYSQL **>(v.data());
36 if (handle) {
37 // ...
38 }
39}
40//! [1]
41}
void checkHandle()