加入copy对像是你用来执行拷贝操作的,
QThread * thread = new QThread();
copy->moveToThread(thread);
thread->start();
connect(copy, SIGNAL(fileExist()), xx, SLOT(XXXX()));
copy->start(files); 开始拷贝文件
---------------------
void Copy::start(const QStringList &files) // 开始拷贝这些文件
{
QTimer::singleShot(0, this, SLOT(copy())); // 这里不执行实际拷贝,通过信号槽间接调用 copy
}
void Copy::copy(const QStringList &files)
{
foreach(QString file, files) {
if(存在) {
emit fileExist(file);
break;
} else {
拷贝文件
}
emit copyFinished();
}
}
这样就不用考虑跨线程的问题了。