Need Help with Using QDataStream
I would like to be able to use QDataStream on a QSqlDatabase object but I have not had any luck getting that to work. I realize now that QSqlDatabase is not a QIODevice, but I was wondering if there was some generic way to serialize the database object? Even if someone has a hint of a way they can steer me towards?
Hi and welcome to devnet,
What is your goal with that ?
A QSqlDatabase object represents a database connection which might not be what you are really looking to serialize.
@SGaist Thank you.
I wanted to serialize the database itself, not the connection, so thank you for clearing that up. I know that with QSQLITE i can save the database to a file and then I can load the file into a QByteArray, and that is kinda serializing the database, but I was hoping to find a way to bypass having to save it as a file. In the worst case scenario, I can do this, but if the database contains sensitive data (like possibly passwords or the like), I would prefer to bypass leaving a copy of the db on the hard drive.
With SQLite, the database is the file, nothing to do with how Qt uses it.
But what is still not clear is what you want to achieve with QDataStream. Where do you want that serialisation to go to ?