From e36c3f700280ecca2d6333987897a3377772d385 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Apr 2010 14:28:32 +1000 Subject: Doc: more mention of using QUrl::fromLocalFile() for URLs on local filesystem --- src/declarative/qml/qdeclarativecomponent.cpp | 6 ++++++ src/declarative/util/qdeclarativeview.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index e180374..d319e8f 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -320,6 +320,9 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QObject Create a QDeclarativeComponent from the given \a url and give it the specified \a parent and \a engine. + Ensure that the URL provided is full and correct, in particular, use + \l QUrl::fromLocalFile() when loading a file from the local filesystem. + \sa loadUrl() */ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QUrl &url, QObject *parent) @@ -409,6 +412,9 @@ QDeclarativeContext *QDeclarativeComponent::creationContext() const /*! Load the QDeclarativeComponent from the provided \a url. + + Ensure that the URL provided is full and correct, in particular, use + \l QUrl::fromLocalFile() when loading a file from the local filesystem. */ void QDeclarativeComponent::loadUrl(const QUrl &url) { diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 22a7873..c0425ef 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -204,7 +204,7 @@ void QDeclarativeViewPrivate::execute() QDeclarativeView *view = new QDeclarativeView(this); vbox->addWidget(view); - QUrl url(fileName); + QUrl url = QUrl::fromLocalFile(fileName); view->setSource(url); view->show(); \endcode @@ -279,11 +279,17 @@ QDeclarativeView::~QDeclarativeView() \brief The URL of the source of the QML component. Changing this property causes the QML component to be reloaded. + + Ensure that the URL provided is full and correct, in particular, use + \l QUrl::fromLocalFile() when loading a file from the local filesystem. */ /*! Sets the source to the \a url, loads the QML component and instantiates it. + Ensure that the URL provided is full and correct, in particular, use + \l QUrl::fromLocalFile() when loading a file from the local filesystem. + Calling this methods multiple times with the same url will result in the QML being reloaded. */ -- cgit v0.12