Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
8
void
checkHandle
()
9
{
10
//dummy definitions
11
typedef
void
sqlite3;
12
typedef
void
PGconn;
13
typedef
void
MYSQL;
14
//! [0]
15
QSqlDatabase db = QSqlDatabase::database();
16
QVariant v = db.driver()->handle();
17
if
(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]
27
if
(qstrcmp(v.typeName(),
"PGconn*"
) == 0) {
28
PGconn *handle = *
static_cast
<PGconn **>(v.data());
29
if
(handle) {
30
// ...
31
}
32
}
33
34
if
(qstrcmp(v.typeName(),
"MYSQL*"
) == 0) {
35
MYSQL *handle = *
static_cast
<MYSQL **>(v.data());
36
if
(handle) {
37
// ...
38
}
39
}
40
//! [1]
41
}
checkHandle
void checkHandle()
Definition
src_sql_kernel_qsqldriver.cpp:8
qtbase
src
sql
doc
snippets
code
src_sql_kernel_qsqldriver.cpp
Generated on
for Qt by
1.18.0