Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QDownloadManager Class

The QDownloadManager class provides asset data download capability. More...

 #include <QDownloadManager>

Inherits: QObject.

This class was introduced in Qt 4.8.

Public Functions

QDownloadManager(QObject * parent = 0)
bool downloadAsset(QUrl assetUrl)
QNetworkAccessManager * getNetworkManager()
  • 31 public functions inherited from QObject

Signals

void downloadComplete(QByteArray * assetData)

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QDownloadManager class provides asset data download capability.

QDownloadManager encapsulates the functions needed for the downloading of asset data (eg. textures) from a network URL (eg. a website).

At the core of QDownloadManager is a QNetworkAccessManager which is shared by all instances of QDownloadManager. The download manager itself provides all handling of network requests and replies internally, and allows for redirection of URLs and handling of errors without the need for the user to query network replies.

To use the QDownloadManager simply create an instance of the class within your code, and connect QDownloadManager's downloadComplete() signal to a slot in your own code, then call the downloadAsset() function.

For example

 QDownloadManager dlmanage;

 connect(this, SLOT(myReceiverSlot(QByteArray*)), &dlmanage, SIGNAL(downloadComplete(QByteArray*)));

 if (!dlmanage.downloadAsset(QUrl("www.my.image.url.net/image.jpg"))) {
     dWarning("the manager was unable to send the url request.");
 }

The QDownloadManager will emit the downloadComplete() signal which contains all of the downloaded data in a QByteArray. It is the user's responsibility to convert this data to the format they require, and to verify that it is correct.

Member Function Documentation

QDownloadManager::QDownloadManager(QObject * parent = 0)

Construct a new instance of the QDownloadManager and attach it to parent. Internally this initialises the QNetworkAccessManager which is shared by instances of this class, if it has not yet been initialised.

bool QDownloadManager::downloadAsset(QUrl assetUrl)

Instructs the QDownloadManager to download the content specified in assetUrl.

A return value of true indicates that the network request was successfully queued/sent, while a return value of false indicates a problem with sending (possibly a poorly specified URL).

void QDownloadManager::downloadComplete(QByteArray * assetData) [signal]

Signals that the download is completed. A successful download will have a valid QByteArray stored in assetData, while a failed download (due to network error, etc), will result in a NULL value.

QNetworkAccessManager * QDownloadManager::getNetworkManager()

Returns a pointer to the underlying QNetworkAccessManager which the QDownloadManager instances use to download content.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web