Can I store a QPointer
, for example a QPointer<QTcpSocket>
inside a QVariant
and later extract it from it?
I tried with:
QObject *ob = new QObject();
QPointer<QObject> qp(ob);
QVariant qv(qp);
But I got an error - QVariant::QVariant(void*)' is private
.
After some more research, it is possible by using
QVariant::fromValue()
andQVariant::value()
.Example code:
This gives: