lundi 29 février 2016

std smart ptrs mixed with raw pointers for Qt

I want to store some QObjects inside smart pointers but Qt classes take only raw pointers as arguments so I'm wondering what does the thing I've done... in class body I have:

QStateMachine states;
std::shared_ptr<QState> some_state = nullptr;

Later I do:

some_state = std::shared_ptr<QState>(new QState());
states.addState(&*some_state);

And how about using std::unique_ptr here? Will it create some ill interaction with raw pointers inside Qt classes?

Aucun commentaire:

Enregistrer un commentaire