QAbstractUriResolver Class

The QAbstractUriResolver class is a callback interface for resolving Uniform Resource Identifiers. A Uniform Resource Identifier (URI) is a string that uniquely identifies a resource. URIs are versatile global identifiers. It is often useful to transform a URI that identifies something logical into a URI that locates something physical (a URL), or to simply map a URI to a different URI. QAbstractUriResolver::resolve() provides this functionality. 更多...

头文件: #include <QAbstractUriResolver>
qmake: QT += xmlpatterns
开始支持版本: Qt 4.4
基类: QObject

Note: All functions in this class are reentrant.

公有函数

QAbstractUriResolver(QObject *parent = Q_NULLPTR)
virtual ~QAbstractUriResolver()
virtual QUrl resolve(const QUrl &relative, const QUrl &baseURI) const = 0
  • 32 个公有函数继承自 QObject

其他继承的成员

  • 1 个属性继承自 QObject
  • 1 个公有槽函数继承自 QObject
  • 2 个信号继承自 QObject
  • 1 个公有变量继承自 QObject
  • 10 个静态公有成员继承自 QObject
  • 9 个受保护的函数继承自 QObject
  • 2 个受保护的变量继承自 QObject

详细描述

The QAbstractUriResolver class is a callback interface for resolving Uniform Resource Identifiers. A Uniform Resource Identifier (URI) is a string that uniquely identifies a resource. URIs are versatile global identifiers. It is often useful to transform a URI that identifies something logical into a URI that locates something physical (a URL), or to simply map a URI to a different URI. QAbstractUriResolver::resolve() provides this functionality.

For example, one could write a QAbstractUriResolver subclass that rewrites library ISBN number URIs as book title URLs, e.g., urn:isbn:0-345-33973-8 would be rewritten as file:///books/returnOfTheKing.doc. Or a QAbstractUriResolver subclass could be written for a web browser to let the web browser protect the user's private files by mapping incoming requests for them to null URIs.

参见 http://en.wikipedia.org/wiki/Uniform_Resource_Identifier.

成员函数

QAbstractUriResolver::QAbstractUriResolver(QObject *parent = Q_NULLPTR)

Constructs a QAbstractUriResolver with the specified parent.

[virtual] QAbstractUriResolver::~QAbstractUriResolver()

Destructor.

[pure virtual] QUrl QAbstractUriResolver::resolve(const QUrl &relative, const QUrl &baseURI) const

Returns the relative URI resolved using the baseURI.

The caller guarantees that both relative and baseURI are valid, and that baseURI is absolute. relative can be relative, absolute, or empty.

The returned QUrl can be a default constructed QUrl. If it is not a default constructed QUrl, it will be absolute and valid. If a default constructed QUrl is returned, it means the relative URI was not accepted to be resolved.

If the reimplemented resolve() function decides it has nothing to do about resolving the relative URI, it should simply return the relative URI resolved against the baseURI, i.e.:


  return baseURI.resolved(relative);

参见 QUrl::isRelative() and QUrl::isValid().