Solved adding another parameter to my networkreply function, makes it fail?
-
I am working with parsing JSON that I grab with a GET request through QNetworkManager and QNetworkReply. I handle the finished reply with a slot which triggers the function requestReceived(QNetworkReply *reply) that then goes through the code and does some json parsing etc.
The problem that I am having is that I want to make the requestReceived function able to take a string parameter in with it so I can perform different operations with the same code.
When I alter the function to requestReceived(QNetworkReply *reply, QString strFlag) the function no longer responds, even though I haven't added any additional code other than changing the function declarations.
Does anyone have any idea why this is?
-
hi and welcome
As far as I know to successfully connect a signal to a slot (or to another signal),
they must have the same parameter types in the same order:
So unless you can change "finished" signal to also have this new parameter ,
im don't think it will accept it.You can check the return value of connect to see if it returns false.
-
Hi and welcome to devnet,
When using signals and slots, both must either have matching signatures or the slot have less parameter than the signal but not the opposite.
-
Hmmm so I guess that would mean that since the finished signal is void QNetworkAccessManager::finished(QNetworkReply * reply) that means I would not be able to add an additional string parameter to the signal to match the slot....
Might have to figure out another way to customize this, just wouldn't want to write a function for each GET request I will make.
-
What kind of parameter do you have in mind ?