[Qt-interest] Custom SQLite Driver

André Somers andre at familiesomers.nl
Sun Nov 29 15:27:21 CET 2009


Would it be sensible to express the key as a property? In that case, you
could use setProperty("key") on your driver, and loose the conversion. Check
out Q_PROPERTY to see how. Perhaps slightly less hackish than using
invokeMethod(), though I use that approach myself quite frequently.

André


-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Mohammed Sameer
Verzonden: zondag 29 november 2009 14:25
Aan: qt-interest at trolltech.com
Onderwerp: Re: [Qt-interest] Custom SQLite Driver

I'm not an expert here but...

On Sun, Nov 29, 2009 at 12:03:16PM +0000, Neville Dastur wrote:
> I am writing a custom SQLite driver to use the encryption routines from 
> wxSqlite. I have got the whole thing compiling and working by following 
> the docs on writing your own driver 
> (http://qt.nokia.com/doc/4.5/qsqldatabase.html#addDatabase-2) , but I am 
> having a problem including a new method.
> 
> To set a password on the database the ReKey function needs to be called. 
> I created a public method:
>  void QSQLiteDriver::ReKey(const QString & key)
> 
> When calling QSQLDatabase m_db->driver()->ReKey("test"); the function 
> ReKey can't be found.
>  and
> 
> QSQLiteDriver *driver = m_db->driver();
> driver->ReKey("test");

QSQLiteDriver *driver = dynamic_cast<QSQLiteDriver *>(m_db->driver()); //
Some might prefer qobject_cast

> What is this the best way of adding new functionality to a QSQLDriver.

Maybe a public slot and then use QMetaObject::invokeMethod() ?

Sounds ugly but I can't find something else ;-)

Cheers,

-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list