for(QThread *&threadDB: threadsDB) { threadDB = new QThread; Worker *worker = new Worker; worker->moveToThread(threadDB); connect(threadDB, &QThread::finished, worker, &QObject::deleteLater); connect(this, &DB::queryWork, worker, &Worker::queryWork); connect(this, &DB::workerConnectDB, worker, &Worker::connectDB); connect(this, &DB::workerDisconnectDB, worker, &Worker::disconnectDB); connect(worker, &Worker::queryResult, this, &DB::queryResult); threadDB->start(); }
C++ (Qt)QMetaObject::invokeMethod(worker, "queryWork");