[Interest] QUrl: changing a single query item's value

Pritam Ghanghas pritam_ghanghas at infosys.com
Mon Nov 7 12:09:43 CET 2011


Hi Mandeep,

I have used removeEncodedQueryItem() and addEncodedQueryItem() in the
past for such requirement. Not exactly inplace modification but it
works. It adds the new item at the end of the original list. if order is
important to you, it may not work.

-- 
Regards,
Pritam


On Mon, 2011-11-07 at 15:52 +0530, Mandeep Sandhu wrote:
> Hi All,
> 
> Why doesn't QUrl have a 'setter' for it's
> QUrl::encodedQueryItemValue() function.
> 
> I have a url which has a lot of query parameters in it. I want to
> change only _one_ of them.
> 
> While I can get the value, using the QUrl::encodedQueryItemValue(),
> and change it. I found it a little surprising that there's no
> QUrl::setEncodedQueryItemValue() for setting a single param!
> 
> Right now, it seems like I have to iterate through the list of query
> items (got via QUrl::encodedQueryItems()) and modify the specific
> param and then set it back using QUrl::setEncodedQueryItems(). While
> this works, it looks quite cumbersome. I tried using
> QUrl::addEncodedQueryItem(), but that 'adds' a new query parameter
> (does not replace the existing one even if the param key is the same).
> 
> Any other simpler way to do this? Should we have a
> QUrl::setEncodedQueryItemValue()?
> 
> Regards,
> -mandeep
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***



More information about the Interest mailing list