在我的代码中,有这样一段:
QThread* thread = new QThread;
Beacon *beacon = new Beacon(beg, end);
beacon->moveToThread(thread);
前几天,我在阅读有关智能指针的内容。如果我理解得正确,它可能适用于上面的代码段中。我尝试了一下:
std::unique_ptr<QThread> thread {new QThread};
std::unique_ptr<Beacon> beacon {new Beacon(beg, end)};
beacon->moveToThread(thread);
这导致:
error: no viable conversion from 'std::unique_ptr<QThread>' to 'QThread *'
beacon->moveToThread(thread);
有什么问题吗?
moveToThread(thread.get())
- Igor Tandetnik