// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include #include #include #include void checkHandle() { //dummy definitions typedef void sqlite3; typedef void PGconn; typedef void MYSQL; //! [0] QSqlDatabase db = QSqlDatabase::database(); QVariant v = db.driver()->handle(); if (v.isValid() && (qstrcmp(v.typeName(), "sqlite3*") == 0)) { // v.data() returns a pointer to the handle sqlite3 *handle = *static_cast(v.data()); if (handle) { // ... } } //! [0] //! [1] if (qstrcmp(v.typeName(), "PGconn*") == 0) { PGconn *handle = *static_cast(v.data()); if (handle) { // ... } } if (qstrcmp(v.typeName(), "MYSQL*") == 0) { MYSQL *handle = *static_cast(v.data()); if (handle) { // ... } } //! [1] }