[Interest] file:// is harshing my zen

Matthew Woehlke mwoehlke.floss at gmail.com
Wed Dec 16 18:27:28 CET 2015


On 2015-12-16 11:33, Jason H wrote:
> I continually run into situations in QML where I'm being given a Url.
> Normally these are file://... When I take my C++ api, expose it to
> QML and pass these values from QML to the C++ api, things don't work,
> and as a result I have to add if (filename.startsWith("file://"))
> {..trim it...} everywhere.

Well, you mentioned toLocalFile, so I assume you already know that "trim
it" should actually use that. Also:

  if (uri.scheme() == "file")

> Why isn't there a *static* QUrl::toLocalFile()?

What would that mean? A URI can be converted to a local file name. What
input would you give such a function other than a URI (i.e. a QUrl)? And
since you have a URI (QUrl) already, why do you need a static method?

Caveat: I don't use QML. If that's giving you QString's that really
should be QUrl's, I'd be complaining about that...

-- 
Matthew




More information about the Interest mailing list