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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QVersitWriter Class Reference

The QVersitWriter class writes Versit documents such as vCards to a device. More...

 #include <QVersitWriter>

Inherits: QObject.

Public Types

enum Error { NoError, UnspecifiedError, IOError, OutOfMemoryError, NotReadyError }
enum State { InactiveState, ActiveState, CanceledState, FinishedState }

Public Functions

QVersitWriter ()
QVersitWriter ( QIODevice * outputDevice )
QVersitWriter ( QByteArray * outputBytes )
~QVersitWriter ()
QTextCodec * defaultCodec () const
QIODevice * device () const
Error error () const
void setDefaultCodec ( QTextCodec * codec )
void setDevice ( QIODevice * device )
State state () const
bool waitForFinished ( int msec = -1 )
  • 29 public functions inherited from QObject

Public Slots

void cancel ()
bool startWriting ( const QList<QVersitDocument> & input )
bool startWriting ( const QList<QVersitDocument> & input, QVersitDocument::VersitType type )
bool startWriting ( const QVersitDocument & input )
bool startWriting ( const QVersitDocument & input, QVersitDocument::VersitType type )
  • 1 public slot inherited from QObject

Signals

void stateChanged ( QVersitWriter::State state )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QVersitWriter class writes Versit documents such as vCards to a device.

QVersitWriter converts a QVersitDocument into its textual representation. QVersitWriter supports writing to an abstract I/O device which can be for example a file or a memory buffer. The writing can be done asynchronously and the waitForFinished() function can be used to implement a blocking write.

The serialization of the document is done in accordance with the type of the QVersitDocument being written. The value of each QVersitProperty is encoded according to the type of object:

  • QStrings are serialized verbatim, unless the default codec of the writer cannot encode the string: in this case, UTF-8 is used to encode it (and the CHARSET parameter added to the property, as per the vCard 2.1 specification). If the document type is vCard 2.1, quoted-printable encoding may also be performed.
  • QByteArrays are assumed to be binary data and are serialized as base-64 encoded values.
  • QVersitDocuments are serialized as a nested document (eg. as per the AGENT property in vCard).

See also QVersitDocument and QVersitProperty.

Member Type Documentation

enum QVersitWriter::Error

This enum specifies an error that occurred during the most recent operation:

ConstantValueDescription
QVersitWriter::NoError0The most recent operation was successful
QVersitWriter::UnspecifiedError1The most recent operation failed for an undocumented reason
QVersitWriter::IOError2The most recent operation failed because of a problem with the device
QVersitWriter::OutOfMemoryError3The most recent operation failed due to running out of memory
QVersitWriter::NotReadyError4The most recent operation failed because there is an operation in progress

enum QVersitWriter::State

Enumerates the various states that a reader may be in at any given time

ConstantValueDescription
QVersitWriter::InactiveState0Write operation not yet started
QVersitWriter::ActiveState1Write operation started, not yet finished
QVersitWriter::CanceledState2Write operation is finished due to cancelation
QVersitWriter::FinishedState3Write operation successfully completed

Member Function Documentation

QVersitWriter::QVersitWriter ()

Constructs a new writer.

QVersitWriter::QVersitWriter ( QIODevice * outputDevice )

Constructs a new writer that writes to outputDevice.

QVersitWriter::QVersitWriter ( QByteArray * outputBytes )

Constructs a new writer that appends to outputBytes.

QVersitWriter::~QVersitWriter ()

Frees the memory used by the writer. Waits until a pending asynchronous writing has been completed.

void QVersitWriter::cancel () [slot]

Attempts to asynchronously cancel the write request.

QTextCodec * QVersitWriter::defaultCodec () const

Returns the document's codec.

See also setDefaultCodec().

QIODevice * QVersitWriter::device () const

Returns the device used for writing, or 0 if no device has been set.

See also setDevice().

Error QVersitWriter::error () const

Returns the error encountered by the last operation.

void QVersitWriter::setDefaultCodec ( QTextCodec * codec )

Sets the default codec for the writer to use for writing the entire output.

If codec is NULL, the writer uses the codec according to the specification prescribed default. (for vCard 2.1, ASCII; for vCard 3.0, UTF-8).

See also defaultCodec().

void QVersitWriter::setDevice ( QIODevice * device )

Sets the device used for writing to device. Does not take ownership of the device.

See also device().

bool QVersitWriter::startWriting ( const QList<QVersitDocument> & input ) [slot]

Starts writing input to device() asynchronously. The serialization format is determined based on the contents of the input documents.

Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.

The device must be already open. The client is responsible for closing it when finished.

bool QVersitWriter::startWriting ( const QList<QVersitDocument> & input, QVersitDocument::VersitType type ) [slot]

Starts writing input to device() asynchronously using the serialization format specified by type. If type is QVersitDocument::InvalidType, the format will be determined based on the contents of the input documents.

Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.

The device must be already open. The client is responsible for closing it when finished.

bool QVersitWriter::startWriting ( const QVersitDocument & input ) [slot]

Starts writing input to device() asynchronously. The serialization format is determined based on the contents of the input documents.

Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.

The device must be already open. The client is responsible for closing it when finished.

bool QVersitWriter::startWriting ( const QVersitDocument & input, QVersitDocument::VersitType type ) [slot]

Starts writing input to device() asynchronously using the serialization format specified by type. If type is QVersitDocument::InvalidType, the format will be determined based on the contents of the input documents.

Returns false if the output device has not been set or opened or if there is another asynchronous write operation already pending. Signal stateChanged() is emitted with parameter FinishedState when the writing has finished.

The device must be already open. The client is responsible for closing it when finished.

State QVersitWriter::state () const

Returns the state of the writer.

void QVersitWriter::stateChanged ( QVersitWriter::State state ) [signal]

The signal is emitted by the writer when its state has changed (eg. when it has finished writing to the device). state is the new state of the writer.

bool QVersitWriter::waitForFinished ( int msec = -1 )

If the state is ActiveState, blocks until the writer has finished writing or msec milliseconds has elapsed, returning true if it successfully finishes or is cancelled by the user. If msec is negative or zero, the function blocks until the writer has finished, regardless of how long it takes. If the state is FinishedState, returns true immediately. Otherwise, returns false immediately.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 48
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 13
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Labs au hasard

Logo

Améliorer les performances de Qt lors du rendu avec plus de SIMD

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 qtmobility-1.2
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