Seite 1 von 1

Qt SQLite handle

Verfasst: 10. März 2009 20:38
von cevou
Hallo ich versuche über sqlite3_enable_load_extension das laden von Extensions in SQLite zu aktivieren.
Leider stürtzt mein Programm immer beim Ausführen des Behels ab?

Hier erstmal mein Code:

Code: Alles auswählen

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<sqlite3 **>(v.data());
            if (handle != 0) { // check that it is not NULL
                sqlite3_enable_load_extension(handle,1);
            }
        }
Hat jemand eine Idee woran das liegen könnte? Ist eventuell das Handle das ich erzeuge irgendwie falsch?

Viele Grüße
Christoph

Verfasst: 10. März 2009 21:05
von solarix

Code: Alles auswählen

sqlite3 *handle = *static_cast<sqlite3 **>(v.data()); 
wusste bisher gar nicht dass es sowas gibt... (data()).. funktionieren denn die dokumentierten Features wie z.B.

Code: Alles auswählen

sqlite3 *handle = v.value<sqlite3*>();  

Verfasst: 10. März 2009 21:11
von cevou
Nein, leider nicht:
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qmetatype.h: In static member function `static int QMetaTypeId2<T>::qt_metatype_id() [with T = sqlite3*]':
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qmetatype.h:194: instantiated from `int qMetaTypeId(T*) [with T = sqlite3*]'
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qvariant.h:561: instantiated from `T qvariant_cast(const QVariant&) [with T = sqlite3*]'
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qvariant.h:574: instantiated from `T qVariantValue(const QVariant&) [with T = sqlite3*]'
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qvariant.h:314: instantiated from `T QVariant::value() const [with T = sqlite3*]'
src\mainwindow.cpp:192: instantiated from here
c:/Programme/Qt/4.5.0-RC/include/QtCore/../../src/corelib/kernel/qmetatype.h:184: error: `qt_metatype_id' is not a member of `QMetaTypeId<sqlite3*>'