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  · 

QTextDocumentWriter Class Reference

The QTextDocumentWriter class provides a format-independent interface for writing a QTextDocument to files or other devices. More...

 #include <QTextDocumentWriter>

This class was introduced in Qt 4.5.

Public Functions

QTextDocumentWriter ()
QTextDocumentWriter ( QIODevice * device, const QByteArray & format )
QTextDocumentWriter ( const QString & fileName, const QByteArray & format = QByteArray() )
~QTextDocumentWriter ()
QTextCodec * codec () const
QIODevice * device () const
QString fileName () const
QByteArray format () const
void setCodec ( QTextCodec * codec )
void setDevice ( QIODevice * device )
void setFileName ( const QString & fileName )
void setFormat ( const QByteArray & format )
bool write ( const QTextDocument * document )
bool write ( const QTextDocumentFragment & fragment )

Static Public Members

QList<QByteArray> supportedDocumentFormats ()

Detailed Description

The QTextDocumentWriter class provides a format-independent interface for writing a QTextDocument to files or other devices.

To write a document, construct a QTextDocumentWriter object with either a file name or a device object, and specify the document format to be written. You can construct a writer and set the format using setFormat() later.

Call write() to write the document to the device. If the document is successfully written, this function returns true. However, if an error occurs when writing the document, it will return false.

Call supportedDocumentFormats() for a list of formats that QTextDocumentWriter can write.

Since the capabilities of the supported output formats vary considerably, the writer simply outputs the appropriate subset of objects for each format. This typically includes the formatted text and images contained in a document.

Member Function Documentation

QTextDocumentWriter::QTextDocumentWriter ()

Constructs an empty QTextDocumentWriter object. Before writing, you must call setFormat() to set a document format, then setDevice() or setFileName().

QTextDocumentWriter::QTextDocumentWriter ( QIODevice * device, const QByteArray & format )

Constructs a QTextDocumentWriter object to write to the given device in the document format specified by format.

QTextDocumentWriter::QTextDocumentWriter ( const QString & fileName, const QByteArray & format = QByteArray() )

Constructs an QTextDocumentWriter object that will write to a file with the name fileName, using the document format specified by format. If format is not provided, QTextDocumentWriter will detect the document format by inspecting the extension of fileName.

QTextDocumentWriter::~QTextDocumentWriter ()

Destroys the QTextDocumentWriter object.

QTextCodec * QTextDocumentWriter::codec () const

Returns the codec that is currently assigned to the writer.

See also setCodec().

QIODevice * QTextDocumentWriter::device () const

Returns the device currently assigned, or 0 if no device has been assigned.

See also setDevice().

QString QTextDocumentWriter::fileName () const

If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file to be written to. In all other cases, it returns an empty string.

See also setFileName() and setDevice().

QByteArray QTextDocumentWriter::format () const

Returns the format used for writing documents.

See also setFormat().

void QTextDocumentWriter::setCodec ( QTextCodec * codec )

Sets the codec for this stream to codec. The codec is used for encoding any data that is written. By default, QTextDocumentWriter uses UTF-8.

See also codec().

void QTextDocumentWriter::setDevice ( QIODevice * device )

Sets the writer's device to the device specified. If a device has already been set, the old device is removed but otherwise left unchanged.

If the device is not already open, QTextDocumentWriter will attempt to open the device in QIODevice::WriteOnly mode by calling open().

Note: This will not work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where some configuration is required before the device can be opened.

See also device() and setFileName().

void QTextDocumentWriter::setFileName ( const QString & fileName )

Sets the name of the file to be written to fileName. Internally, QTextDocumentWriter will create a QFile and open it in QIODevice::WriteOnly mode, and use this file when writing the document.

See also fileName() and setDevice().

void QTextDocumentWriter::setFormat ( const QByteArray & format )

Sets the format used to write documents to the format specified. format is a case insensitive text string. For example:

         QTextDocumentWriter writer;
         writer.setFormat("odf"); // same as writer.setFormat("ODF");

You can call supportedDocumentFormats() for the full list of formats QTextDocumentWriter supports.

See also format().

QList<QByteArray> QTextDocumentWriter::supportedDocumentFormats () [static]

Returns the list of document formats supported by QTextDocumentWriter.

By default, Qt can write the following formats:

FormatDescription
plaintextPlain text
HTMLHyperText Markup Language
ODFOpenDocument Format

See also setFormat().

bool QTextDocumentWriter::write ( const QTextDocument * document )

Writes the given document to the assigned device or file and returns true if successful; otherwise returns false.

bool QTextDocumentWriter::write ( const QTextDocumentFragment & fragment )

Writes the document fragment specified by fragment to the assigned device or file and returns true if successful; otherwise returns false.

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 4.8
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