PDA

View Full Version : How can I send a SQLite :memory: database connection ?



georgep
19th July 2009, 23:09
I have a non-default SQLite database connection created in a class. I .setdatabasename(:memory:) and then create a table.
How do I access the SAME database from another class ?

I tried sending the QSqlDatabase through a signal but the database became "blank" (no tables besides master).
I tried QSqlDatabase sqlite = QSqlDatabase::database("already-established"); (within the new class) but with the same result.
Is what I am trying to do logically wrong?


ps:pls dont tell me to use default connection.
Thanks

wysota
20th July 2009, 00:24
QSqlDatabase::database("name") should work provided you opened the connection called "name" earlier on using addDatabase().

georgep
20th July 2009, 00:48
thank you for replying !
Yes, thats what I read in the documentation. But it didnt :<. The connection appeared "the same", only there were no tables.

If i pass QSqlDatabase *db then it appears to work.

wysota
20th July 2009, 01:14
Can you show us the respective code? Especially the part where you create the connection and where you pass it to the other part of the application.

georgep
20th July 2009, 12:07
Heh, no need. I tried it again this morning and It worked as it supposed to. Dunno what was wrong last night. Sorry..