It's not possible. You would have to terminate the thread execution since QSqlQuery::exec() is a blocking function. However, aborting a thread is not recommended, as the documentation states:

Warning: This function is dangerous and its use is discouraged. The thread can be terminate at any point in its code path. Threads can be terminated while modifying data. There is no chance for the thread to cleanup after itself, unlock any held mutexes, etc. In short, use this function only if absolutely necessary.
In the end, if you want to be able to safely abort a query, the only suitable way I can think of is creating a child process that performs the queries and killing it when you need to abort the query.

However, if you're not going to abort the query very often, you may try with terminate(), keeping in mind it's risky and it can produce crashes, memory leaks and so on. I'm using terminate() in my application and it's working fine but I normally don't need to call it, it's a last-resort.