PDA

View Full Version : Send shared_ptr using signal



theZivkovic
18th September 2015, 18:52
I have a thread which makes a huge object
and I want to pass it using qt signal back to main thread.

Can I pass the shared_ptr (c++11) reffering to that object,
and how?

anda_skoa
18th September 2015, 20:48
You need to declare the specialized shared pointer type with Q_DECLARE_METATYPE and call qRegisterMetaType() somewhen before using the signal.

http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE

Cheers,
_