Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlFile Class Reference

\inmodule QtQml More...

#include <qqmlfile.h>

+ Collaboration diagram for QQmlFile:

Public Types

enum  Status { Null , Ready , Error , Loading }
 

Public Member Functions

 QQmlFile ()
 
 QQmlFile (QQmlEngine *engine, const QUrl &url)
 
 QQmlFile (QQmlEngine *engine, const QString &url)
 
 ~QQmlFile ()
 
bool isNull () const
 
bool isReady () const
 
bool isError () const
 
bool isLoading () const
 
QUrl url () const
 
Status status () const
 
QString error () const
 
qint64 size () const
 
const char * data () const
 
QByteArray dataByteArray () const
 
void load (QQmlEngine *, const QUrl &)
 
void load (QQmlEngine *, const QString &)
 
void clear ()
 
void clear (QObject *object)
 

Static Public Member Functions

static bool isSynchronous (const QString &url)
 
static bool isSynchronous (const QUrl &url)
 
static bool isLocalFile (const QString &url)
 Returns true if url is a local file that can be opened with \l{QFile}.
 
static bool isLocalFile (const QUrl &url)
 Returns true if url is a local file that can be opened with \l{QFile}.
 
static QString urlToLocalFileOrQrc (const QString &)
 If url is a local file returns a path suitable for passing to \l{QFile}.
 
static QString urlToLocalFileOrQrc (const QUrl &)
 If url is a local file returns a path suitable for passing to \l{QFile}.
 

Detailed Description

\inmodule QtQml

Since
5.0

The QQmlFile class provides static utility methods to categorize URLs.

QQmlFile provides some static utility methods to categorize URLs and file names the way \l{QQmlEngine} does when loading content from them.

Definition at line 17 of file qqmlfile.h.

Member Enumeration Documentation

◆ Status

\value Null \value Ready \value Error \value Loading

Enumerator
Null 
Ready 
Error 
Loading 

Definition at line 25 of file qqmlfile.h.

Constructor & Destructor Documentation

◆ QQmlFile() [1/3]

QQmlFile::QQmlFile ( )

Definition at line 176 of file qqmlfile.cpp.

◆ QQmlFile() [2/3]

QQmlFile::QQmlFile ( QQmlEngine * engine,
const QUrl & url )

Constructs a QQmlFile for content at url, using engine to retrieve it.

Definition at line 185 of file qqmlfile.cpp.

References engine, load(), and url().

+ Here is the call graph for this function:

◆ QQmlFile() [3/3]

QQmlFile::QQmlFile ( QQmlEngine * engine,
const QString & url )

Constructs a QQmlFile for content at url, using engine to retrieve it.

Definition at line 195 of file qqmlfile.cpp.

◆ ~QQmlFile()

QQmlFile::~QQmlFile ( )

Definition at line 203 of file qqmlfile.cpp.

Member Function Documentation

◆ clear() [1/2]

void QQmlFile::clear ( )

Definition at line 388 of file qqmlfile.cpp.

References QQmlFilePrivate::data, QQmlFilePrivate::error, QQmlFilePrivate::None, QByteArray(), QQmlFilePrivate::url, and QQmlFilePrivate::urlString.

Referenced by clear(), load(), and load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear() [2/2]

void QQmlFile::clear ( QObject * object)

Redirects to the other clear() overload, ignoring object.

Definition at line 400 of file qqmlfile.cpp.

References clear(), and Q_UNUSED.

+ Here is the call graph for this function:

◆ data()

const char * QQmlFile::data ( ) const

Definition at line 300 of file qqmlfile.cpp.

References QByteArray::constData(), and QQmlFilePrivate::data.

+ Here is the call graph for this function:

◆ dataByteArray()

QByteArray QQmlFile::dataByteArray ( ) const

Definition at line 308 of file qqmlfile.cpp.

References QQmlFilePrivate::data.

◆ error()

QString QQmlFile::error ( ) const

◆ isError()

bool QQmlFile::isError ( ) const

Definition at line 231 of file qqmlfile.cpp.

References Error, and status().

+ Here is the call graph for this function:

◆ isLoading()

bool QQmlFile::isLoading ( ) const

Definition at line 239 of file qqmlfile.cpp.

References Loading, and status().

+ Here is the call graph for this function:

◆ isLocalFile() [1/2]

bool QQmlFile::isLocalFile ( const QString & url)
static

Returns true if url is a local file that can be opened with \l{QFile}.

Otherwise returns false. Local file urls have either a {qrc:} or {file:} scheme.

Note
On Android, urls with {assets:} or {content:} scheme are also considered local files.

Definition at line 644 of file qqmlfile.cpp.

References authorityOffset(), Qt::CaseInsensitive, file_string, hasScheme(), qrc_string, and url().

Referenced by QQmlImports::addFileImport(), importImp(), QQmlImportDatabase::importPathList(), QQmlSettingsPrivate::instance(), load(), load(), QV4::CompiledData::CompilationUnit::loadFromDisk(), QQmlImportDatabase::locateLocalQmldir(), QQuickStyleSpec::path(), QQmlXmlListModel::reload(), and QV4::CompiledData::CompilationUnit::saveToDisk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocalFile() [2/2]

bool QQmlFile::isLocalFile ( const QUrl & url)
static

Returns true if url is a local file that can be opened with \l{QFile}.

Otherwise returns false. Local file urls have either a {qrc:} or {file:} scheme.

Note
On Android, urls with {assets:} or {content:} scheme are also considered local files.

Definition at line 563 of file qqmlfile.cpp.

References QUrl::authority(), Qt::CaseInsensitive, file_string, QString::isEmpty(), QString::length(), qrc_string, QUrl::scheme(), QString::size(), QString::startsWith(), and url().

+ Here is the call graph for this function:

◆ isNull()

bool QQmlFile::isNull ( ) const

Definition at line 215 of file qqmlfile.cpp.

References Null, and status().

+ Here is the call graph for this function:

◆ isReady()

bool QQmlFile::isReady ( ) const

Definition at line 223 of file qqmlfile.cpp.

References Ready, and status().

+ Here is the call graph for this function:

◆ isSynchronous() [1/2]

bool QQmlFile::isSynchronous ( const QString & url)
static

Returns true if QQmlFile will open url synchronously. Otherwise returns false. Synchronous urls have a {qrc:} or {file:} scheme.

Note
On Android, urls with {assets:} or {content:} scheme are also considered synchronous.

Definition at line 508 of file qqmlfile.cpp.

References Qt::CaseInsensitive, file_string, qrc_string, and url().

Referenced by QQmlTypeLoader::getType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSynchronous() [2/2]

bool QQmlFile::isSynchronous ( const QUrl & url)
static

Returns true if QQmlFile will open url synchronously. Otherwise returns false. Synchronous urls have a {qrc:} or {file:} scheme.

Note
On Android, urls with {assets:} or {content:} scheme are also considered synchronous.

Definition at line 478 of file qqmlfile.cpp.

References Qt::CaseInsensitive, QString::compare(), file_string, QString::length(), qrc_string, QUrl::scheme(), QString::size(), and url().

+ Here is the call graph for this function:

◆ load() [1/2]

void QQmlFile::load ( QQmlEngine * engine,
const QString & url )

Loads content at url using engine.

Definition at line 351 of file qqmlfile.cpp.

References QQmlFilePrivate::CaseMismatch, clear(), QQmlFilePrivate::data, engine, QQmlFilePrivate::error, file, isLocalFile(), QQmlFilePrivate::NotFound, QFile::open(), Q_ASSERT, QQml_isFileCaseCorrect(), QIODevice::readAll(), QIODeviceBase::ReadOnly, QQmlFilePrivate::url, url(), QQmlFilePrivate::urlString, and urlToLocalFileOrQrc().

+ Here is the call graph for this function:

◆ load() [2/2]

void QQmlFile::load ( QQmlEngine * engine,
const QUrl & url )

Loads content at url using engine.

Definition at line 317 of file qqmlfile.cpp.

References QQmlFilePrivate::CaseMismatch, clear(), QQmlFilePrivate::data, engine, QQmlFilePrivate::error, file, isLocalFile(), QQmlFilePrivate::NotFound, QFile::open(), Q_ASSERT, QQml_isFileCaseCorrect(), QIODevice::readAll(), QIODeviceBase::ReadOnly, QQmlFilePrivate::url, url(), and urlToLocalFileOrQrc().

Referenced by QQmlFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

qint64 QQmlFile::size ( ) const

Definition at line 292 of file qqmlfile.cpp.

References QQmlFilePrivate::data, and QByteArray::size().

+ Here is the call graph for this function:

◆ status()

QQmlFile::Status QQmlFile::status ( ) const

Definition at line 259 of file qqmlfile.cpp.

References QQmlFilePrivate::error, Error, QUrl::isEmpty(), QString::isEmpty(), Loading, QQmlFilePrivate::None, Null, Ready, QQmlFilePrivate::url, and QQmlFilePrivate::urlString.

Referenced by isError(), isLoading(), isNull(), and isReady().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ url()

QUrl QQmlFile::url ( ) const

Definition at line 247 of file qqmlfile.cpp.

References QString::isEmpty(), QQmlFilePrivate::url, and QQmlFilePrivate::urlString.

Referenced by QQmlFile(), isLocalFile(), isLocalFile(), isSynchronous(), isSynchronous(), load(), load(), urlToLocalFileOrQrc(), and urlToLocalFileOrQrc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urlToLocalFileOrQrc() [1/2]

QString QQmlFile::urlToLocalFileOrQrc ( const QString & url)
static

If url is a local file returns a path suitable for passing to \l{QFile}.

Otherwise returns an empty string.

See also
isLocalFile

Definition at line 742 of file qqmlfile.cpp.

References Qt::CaseInsensitive, hasScheme(), isDoubleSlashed(), Q_ASSERT, QStringLiteral, toLocalFile(), and url().

Referenced by QQmlTypeLoader::absoluteFilePath(), QQmlImports::addFileImport(), QQmlImportDatabase::addImportPath(), QQuickFileDialogDelegatePrivate::chooseFile(), QQuickPdfDocument::classBegin(), QV4::ExecutionEngine::compileModule(), QQuickFolderListModel::componentComplete(), createPixmapDataSync(), QQuickFolderBreadcrumbBarPrivate::crumbPathsForFolder(), QQmlTypeLoader::fileExists(), QQuickControlsTestUtils::forEachControl(), QQuick3DPhysicsHeightFieldManager::getHeightField(), QQuick3DPhysicsMeshManager::getMesh(), QQmlTypeLoader::getQmldir(), QQmlTypeLoader::getScript(), QQmlTypeLoader::getType(), QQuickFolderBreadcrumbBarPrivate::goUp(), importImp(), QQmlSettingsPrivate::instance(), QQmlImports::isLocal(), QQmlImports::isLocal(), QQuickTextDocumentPrivate::load(), QQuickAnimatedImage::load(), QQuickBorderImage::load(), load(), load(), QV4::CompiledData::CompilationUnit::loadFromDisk(), QQuickVectorImagePrivate::loadSvg(), QV4::CompiledData::CompilationUnit::localCacheFilePath(), QQmlImportDatabase::locateLocalQmldir(), QV4Include::method_include(), QQuickFileDialog::onShow(), QQuickFolderDialog::onShow(), QQmlError::operator<<(), QQuickStyleSpec::path(), QSGRhiGuiThreadShaderEffectManager::prepareShaderCode(), QQmlTypeLoader::qmldirContent(), QWavefrontMesh::readData(), QQmlXmlListModel::reload(), QQuickImageBase::resolve2xLocalFile(), resolveImagePath(), QQuickFolderListModelPrivate::resolvePath(), QSSGShaderUtils::resolveShader(), QQmlImportInstance::resolveType(), QQuickFileDialogImpl::setCurrentFolder(), QQuickFolderDialogImpl::setCurrentFolder(), QQuickFontLoader::setSource(), QQuickPdfDocument::setSource(), QQuickImageSelector::setUrl(), QQmlApplicationEnginePrivate::startLoad(), QQmlApplicationEnginePrivate::startLoad(), QQuickFolderBreadcrumbBarPrivate::toggleTextFieldVisibility(), QQuick3DModel::translateMeshSource(), QQuickFileDialogImplPrivate::updateSelectedFile(), QQuickFolderDialogImplPrivate::updateSelectedFolder(), QQuick3DModel::updateSpatialNode(), TestHTTPServer::wait(), and QQmlPreviewFileLoader::whitelist().

+ Here is the call graph for this function:

◆ urlToLocalFileOrQrc() [2/2]

QString QQmlFile::urlToLocalFileOrQrc ( const QUrl & url)
static

If url is a local file returns a path suitable for passing to \l{QFile}.

Otherwise returns an empty string.

See also
isLocalFile

Definition at line 688 of file qqmlfile.cpp.

References QUrl::authority(), Qt::CaseInsensitive, QString::compare(), QString::isEmpty(), QUrl::path(), QUrl::scheme(), QUrl::toLocalFile(), QUrl::toString(), and url().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: