samedi 29 octobre 2016

smart pointer and QThread issue

At some point in my code I have:

QThread* thread = new QThread;
Beacon *beacon = new Beacon(beg, end);
beacon->moveToThread(thread);

And the other day I was reading about this thing called smart pointer. If I understand, it might fit in the peace of code above, I tried:

std::unique_ptr<QThread> thread {new QThread};
std::unique_ptr<Beacon> beacon {new Beacon(beg, end)};
beacon->moveToThread(thread);

This, led to:

error: no viable conversion from 'std::unique_ptr<QThread>' to 'QThread *'
    beacon->moveToThread(thread);

What's wrong?

Aucun commentaire:

Enregistrer un commentaire