Using std::unique_ptr<> in a signal/slot argument.



  • Hi,

    I'm trying to send a custom c++ object from a QThread to a slot in the main thread using the standard Qt signal/slot mechanism. I'm registering my custom type using qRegisterMetaType() and it all works well... please see this gist for a short code snippet:

    https://gist.github.com/landersson/11ff00b40cedf5f8f60f

    The problem is, when I add an std::unique_ptr<> member to my custom class, my object is no longer copy-constructible, and qRegisterMetaType() fails. If I use a plain old pointer it works just fine.

    My question is:

    Is there any way to send objects that are moveable (i.e have C++11 move semantics) but are NOT copyable via the Qt signal/slot mechanism?



  • After doing some more research, I've realized that, since it should be possible to send a signal to multiple slots, using a unique_ptr in (or as a member of) signal arguments is probably not a good idea, or even possible.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.