Sorry to dredge up an old post but I have recently had to add my own custom functions to Qt's SQLite drivers and had many of the same problems. Now that I have resolved them and got my code working, I thought I'd add to this post because I found it when searching and it didn't really help me solve the problem so I thought I'd include my solution(s) so anyone else arriving here might save some effort.
There are two ways to go about getting the custom functions to work:
get the sqlite3* pointer from the db as described above. (sqlite3* handler = *static_cast<sqlite3**>(v.data())

.
However, if you do it this way, there are some things you need to know:
- You must compile your code to link against sqlite3 (which you will have to install separately from Qt as it doesn't contain enough sqlite so that you could link against it). I just used the unified sqlite header and source files and added them into my project directly rather than linking to a library.
- It seems that you need to be very careful to ensure that the version of sqlite that you link to is exactly the same as the version that Qt used when it was built. Look at the sources for Qt if you need to check.
- When I compiled my code, I had to add the -DSQLITE_THREADSAFE=0 (this was for Qt 4.8) otherwise I got a seg fault in create_function.
The disadvantage of this approach is that you will need to change your source to match whatever version of Qt you are using.
The approach I ended up using was to create my own version of the SQLite database driver. I just copied the relevant code from the Qt source and modified it to use a my local copy of SQLite instead of Qt's version. I also added my custom functions in when the database opens in the driver.
I hope some of this info might help anyone that ends up looking at this page after trying to find help with this problem.
Bookmarks