Hello.
1)I have a class (doesn't work with gui), where I have slot for connect to the database(PSQL)
MyClass * cl = new MyClass;
MyClass * cl = new MyClass;
To copy to clipboard, switch view to plain text mode
2)next i create new thread
myclass->moveToThread(thread);
thread->start();
..
emit connectToDB();
...
QThread * thread = new QThread;
myclass->moveToThread(thread);
thread->start();
..
emit connectToDB();
...
To copy to clipboard, switch view to plain text mode
3)next make query in gui-class or myclass;
query.prepare("text here");
query.exec(); //
QSqlQuery query;
query.prepare("text here");
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?
Bookmarks