Your query is not hooked to a database connection. You have to do this before the query.prepare statement.

If you look at this: http://doc.trolltech.com/4.5/qtsql.html#details

You can see how to do it.
as Lykurg said,

query.prepare(...
query.addBindValue(....
query.exec();