I am having trouble emit()ing a QHash<QString, QVariant> ...
when I do
QHash<QString, QVariant> payload;
payload["variable"]="abc";
emit(doCommand(payload));
QHash<QString, QVariant> payload;
payload["variable"]="abc";
emit(doCommand(payload));
To copy to clipboard, switch view to plain text mode
and then
void receiver::doCommand(QHash<QString, QVariant> command)
{
qDebug() << "The variable was: " << command["variable"].toString();
}
void receiver::doCommand(QHash<QString, QVariant> command)
{
qDebug() << "The variable was: " << command["variable"].toString();
}
To copy to clipboard, switch view to plain text mode
I end up with an empty string.
Do I have to register the QHash type, or create a typedef, or is the problem that because "payload" in the first piece of code is not a pointer, and therefore can fall out of scope, it is deleted, or perhaps it cannot be passed by value?
It seems that when I emit a signal with a container (or perhaps just a template), the data gets lost.
Bookmarks