Hello.
1)I have a class (doesn't work with gui), where I have slot for connect to the database(PSQL)
Qt Code:
  1. MyClass * cl = new MyClass;
To copy to clipboard, switch view to plain text mode 
2)next i create new thread
Qt Code:
  1. QThread * thread = new QThread;
  2. myclass->moveToThread(thread);
  3. thread->start();
  4. ..
  5. emit connectToDB();
  6. ...
To copy to clipboard, switch view to plain text mode 

3)next make query in gui-class or myclass;
Qt Code:
  1. QSqlQuery query;
  2. query.prepare("text here");
  3. query.exec(); //
To copy to clipboard, switch view to plain text mode 
4)
Threads and the SQL Module

A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported.
why query.exec() return true with correct data in gui-thread and another thread?