Please nominate your Qt Champions for 2021!

QMap Signal/Slot issue

  • Hi, I have a problem with Signal and Slot.
    I have an object that contains a QMap<quint64,QString> and other variable members. I emit the object as signal and receive it as slot. The object that I receive has all the members of the object emitted except the QMap which is empty.

    I tried to qDebug() the map just before emit and in the slot and it looks like the map existed before and was empty after...

    Can anybody help?



  • Lifetime Qt Champion

    Have you tested that Your class is copyable ?
    I assume when the class is emitted its a copy and not the actual class, as in a pointer?

    void TestFunc( YourClass A) { // no * or & here
    is lists still filled here for A

    YourClass mine;
    // fill the qmap

  • Thanks for the answer.
    Yes my object is copyable. I made a copy just before to emit the object and printed it out , the QMap...QMap is present in the copy, then I emit the object and I get it in the slot..the copy in the slot has QMap empty.

  • Lifetime Qt Champion


    Can you share the code where you emit the signal ?

  • Hi, it is my bad...mrjj was right, I did an incorrect test. The object is not copyable...I have to make it copyable first..that is the reason why I see the issue probably. Thanks

Log in to reply