[Interest] file:// is harshing my zen

Jason H jhihn at gmx.com
Wed Dec 16 17:33:54 CET 2015


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. This is harshing my Qt zen. Am I just not groking something simple? Why cant QFile see "file://" and handle it? Why isn't there a *static* QUrl::toLocalFile()? I realize that when you use things like an image provider, that the protocol matters. But it would be really cool if QFile and other classes could just take a URL that protocol and run it through appropriately, so I can QFile f("imageprovider://some/file"); f.open(QIODevice::ReadOnly); f.read()...

Usually things in Qt are pretty zen. So I suspect I'm missing something obvious. Or am I just head of the curve for once?



More information about the Interest mailing list