Hello, I am having problems copying one QMap to another, any help would be appreciated.
This is my code (where the copying should occur):
PS. I have solved the issue, seems I just had to add i++ to the code below; Just one question, it seems
the data is added in the reverse order to the Qmap. For example, when I added "param1","test1"
key value pair to the QMap as in the end of this post, and also "param2", "test2" ... they are read in an reverse
order in the loop below. Is it supposed to be like this?? I want the data to be added in the
same order as I added in the code in the end.. Thanks.
bool MyNetworkClass::initializeRequestParam(QMap<QString, QString> params)
{
QMap<QString, QString>::const_iterator i = params.constBegin();
while (i != params.constEnd()) {
requestParameters.insert(i.key(), i.value());
i++; // added
}
return true; // this is default...
}
bool MyNetworkClass::initializeRequestParam(QMap<QString, QString> params)
{
QMap<QString, QString>::const_iterator i = params.constBegin();
while (i != params.constEnd()) {
requestParameters.insert(i.key(), i.value());
i++; // added
}
return true; // this is default...
}
To copy to clipboard, switch view to plain text mode
where
requestParameters
requestParameters
To copy to clipboard, switch view to plain text mode
is member variable:
QMap<QString, QString> requestParameters;
QMap<QString, QString> requestParameters;
To copy to clipboard, switch view to plain text mode
Now, when I try to issue the above function:
MyNetworkClass *p = new MyNetworkClass();
QMap<QString, QString> params;
params.insert("param1", "test1");
params.insert("param2", "test2");
params.insert("param3", "test3");
p->initializeRequestParam(params);
MyNetworkClass *p = new MyNetworkClass();
QMap<QString, QString> params;
params.insert("param1", "test1");
params.insert("param2", "test2");
params.insert("param3", "test3");
p->initializeRequestParam(params);
To copy to clipboard, switch view to plain text mode
The last line "initializeRequestParam" - seems to not work.. I think it gets in an endless loop...
when I debugged into it, I think it managed to successfully copy only one "param1", "test1" pair to the
reqestParameters
reqestParameters
To copy to clipboard, switch view to plain text mode
destination...
Any help greatly appreciated as to how to make this function initializeRequestParam work?? and copy one QMap into another..???
Bookmarks