在我的代码中的一些问题,我有:智能指针和QThread的问题
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())' –