Quote Originally Posted by toufic.dbouk View Post
so should i connect to the database in the main GUI ? or in the class subcalssing QObject ?
I would do it in the qobject class, in the slot that executes the query or in a slot connected to the thread's started signal.

Quote Originally Posted by toufic.dbouk View Post
the other problem is that if i start the thread on pressing the button in the dialog , the thread will get destroyed before doing the query
Why would it? The default implementation of QThread::run() runs an event loop. it doesn't finish until QThread::exit() is called.

Quote Originally Posted by toufic.dbouk View Post
where to create the intsnance of the class subclassing QObject ?
When you create the thread. Since you want to directly connect the dialog to the query slot, before you create the dialog or even when you create the applicatIons' main GUI.

Quote Originally Posted by toufic.dbouk View Post
since my query takes parameters , i should pass them to the Thread. How to do that ? Signals and Slots are not doing the job properly in my case
Signals can transport parameters to the slot.
Does it work if you do not use a thread and have the query class instance in the main thread?

Cheers,
_