QAdvanced Item View  0.4
The QAIV (Qt Advanced Item Views) library provides GUI and utility classes extending the capabilities of the Qt item views.
 All Classes Functions Variables Enumerations Enumerator Properties Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
QTableModelWriter Class Reference

The QTableModelWriter class provides a format-independent interface for writing the content of table views to files or other devices. More...

#include <qtablemodelwriter.h>

Public Member Functions

 QTableModelWriter ()
 QTableModelWriter (QIODevice *device, const QByteArray &format)
 QTableModelWriter (const QString &fileName, const QByteArray &format=QByteArray())
 ~QTableModelWriter ()
QIODevice * device () const
QString fileName () const
QByteArray format () const
void setDevice (QIODevice *device)
void setFormat (const QByteArray &format)
void setIncludeHeader (bool on)
void setRole (int role)
bool writeAll (QAdvancedTableView *view)
bool writeAll (QTableView *view)
bool writeSelection (QTableView *view)
bool writeSelection (QAdvancedTableView *view)

Static Public Member Functions

static QList< QByteArray > supportedFormats ()

Detailed Description

The QTableModelWriter class provides a format-independent interface for writing the content of table views to files or other devices.

To write the content of a table, construct a QTableModelWriter object with either a file name or a device object, and specify the format to be written. Call writeAll() to write the content to the device. If the content is successfully written, this function returns true. However, if an error occurs when writing the content, it will return false.

QTableModelWriter writer("c:/temp/qaiv.html");

You can use writeSelection() write the table view's current selection to the device. Additionally, you can construct a writer and set the format using setFormat() later. Call supportedDocumentFormats() for a list of formats that QTableModelWriter can write.

Constructor & Destructor Documentation

QTableModelWriter::QTableModelWriter ( )

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

QTableModelWriter::QTableModelWriter ( QIODevice *  device,
const QByteArray &  format 

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

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

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

QTableModelWriter::~QTableModelWriter ( )

Destroys the QTableModelWriter object.

Member Function Documentation

QIODevice * QTableModelWriter::device ( ) const

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

QString QTableModelWriter::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.

QByteArray QTableModelWriter::format ( ) const

Returns the format used for writing documents.

void QTableModelWriter::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, QTableModelWriter will attempt to open the device in QIODevice::WriteOnly mode by calling open(). This will not work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where some configuration is required before the device can be opened.

void QTableModelWriter::setFormat ( const QByteArray &  format)

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

writer.setFormat("html"); // same as writer.setFormat("HTML");

You can call supportedFormats() for the full list of formats QTableModelWriter supports.

See also
void QTableModelWriter::setIncludeHeader ( bool  on)

If on is true, the table header is included in the output.

QList< QByteArray > QTableModelWriter::supportedFormats ( )

Returns the list of document formats supported by QTextDocumentWriter. By default, you can write the following formats:

CSVComma-separated values
HTMLHyperText Markup Language
SpreadsheetMLMS Excel XML Spreadsheer
WordMLMS Word XML Document
See also
bool QTableModelWriter::writeAll ( QAdvancedTableView view)

Writes all rows and colums of the specified view.

bool QTableModelWriter::writeAll ( QTableView *  view)

Writes all rows and colums of the specified view.

bool QTableModelWriter::writeSelection ( QTableView *  view)

Writes the selected cells of the specified view.

bool QTableModelWriter::writeSelection ( QAdvancedTableView view)

Writes the selected cells of the specified view.

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