Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to register custom pointer so that signal/slot can use it?



  • I want to pass 2 custom pointers using signal/slot.
    My signal is defined as

    void createTimerRequest(const timer::CreateTimerRequest* request, std::promise<timer::CreateTimerReply_Status> *promise);
    

    I try to use

    qRegisterMetaType<std::promise<timer::CreateTimerReply_Status>*>("std::promise<timer::CreateTimerReply_Status>*");
    qRegisterMetaType<timer::CreateTimerRequest*>("timer::CreateTimerRequest*");
    

    But it doesnot work. The slot function is no called.
    Any ideas??

    Thank you.


  • Moderators

    You have to also declare these types using Q_DECLARE_METATYPE. When calling connect check if the return value is true. If not, look for warnings printed to terminal. If there are warnings, post them here.



  • Oh, my fault. My eventloop is dead lock. No need to register pointer, in fact.


Log in to reply