[Development] Converting types in Qt

Konrad Rosenbaum konrad at silmor.de
Fri Jul 18 11:06:53 CEST 2014


On Thursday 17 July 2014 21:31:31 André Pönitz wrote:
> PS: Random side-track question: How comparable are values of type 'int'
> and 'QUrl' if one applies 'common sense'? I even accept answer related
> to non-0 int values only.

The trouble with common sense is that it is not very common in any sense - 
neither do a lot of people have it, nor do the remainder share a common 
vision of it... ;-)

I'll try anyway...

Intuitive answer without a specific use case in mind: they are not 
comparable at all - an int is a completely different beast from a URL.

Answer with weird use cases in mind: the int could represent the path of a 
relative URL. E.g. I could create a cache directory in which I enumerate my 
resources with a simple int counter (cyrus IMAPd does something similar for 
mail storage) and finally express this as a relative URL - as a transient 
conversion int->string->URL.

I could also imagine the int representing the host (IPv4 address) or port of 
the URL, but it gets really weird once you attempt to go there with 
automatic conversions and try to reconcile the result with RFC3986.

In short: an int is just too ambiguous in relation to a URL to justify an 
automatic conversion.



	Konrad



More information about the Development mailing list