Details
-
Suggestion
-
Resolution: Unresolved
-
P5: Not important
-
None
-
5.4.1
-
None
Description
Suppose I want to pass QUrl to my QML code, like so:
QQmlEngine engine; engine.rootContext()->setContextProperty("contextUrl", QUrl{"http://google.com"}); QQmlComponent component(&engine); component.setData(R"( import QtQml 2.2 QtObject { Component.onCompleted: { console.log("URL = " + contextUrl.scheme); } } )", QUrl{}); qDebug() << component.create();
That does not work, as 'scheme' ends up undefined, as well as every other method that QUrl has, so one has to take URL as string, and use regexp to manipulate it, and that's quite painful and likely to result in bugs.
It looks like in Qt 5.4.1, QV8Engine::fromVariant has special handling for QDateTime or for QRegexp, but not for QUrl. In git dev branch, the code has moved to QV4::ExecutionEngine::fromVariant, but there's no handling for QUrl either. As result, just QVariant is exported to QML, which toString as the only useful method.
If would be really good if a custom wrapper for QUrl were created.
Attachments
Issue Links
- relates to
-
QTBUG-46430 QML url type needs more features
- Closed