#[repr(C)]
pub struct QTextDocumentWriter { /* private fields */ }
Expand description

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

C++ class: QTextDocumentWriter.

C++ documentation:

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.

Implementations§

source§

impl QTextDocumentWriter

source

pub unsafe fn codec(&self) -> Ptr<QTextCodec>

Returns the codec that is currently assigned to the writer.

Calls C++ function: QTextCodec* QTextDocumentWriter::codec() const.

C++ documentation:

Returns the codec that is currently assigned to the writer.

See also setCodec().

source

pub unsafe fn device(&self) -> QPtr<QIODevice>

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

Calls C++ function: QIODevice* QTextDocumentWriter::device() const.

C++ documentation:

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

See also setDevice().

source

pub unsafe fn file_name(&self) -> CppBox<QString>

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.

Calls C++ function: QString QTextDocumentWriter::fileName() const.

C++ documentation:

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().

source

pub unsafe fn format(&self) -> CppBox<QByteArray>

Returns the format used for writing documents.

Calls C++ function: QByteArray QTextDocumentWriter::format() const.

C++ documentation:

Returns the format used for writing documents.

See also setFormat().

source

pub unsafe fn new() -> CppBox<QTextDocumentWriter>

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

Calls C++ function: [constructor] void QTextDocumentWriter::QTextDocumentWriter().

C++ documentation:

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

source

pub unsafe fn from_q_io_device_q_byte_array( device: impl CastInto<Ptr<QIODevice>>, format: impl CastInto<Ref<QByteArray>> ) -> CppBox<QTextDocumentWriter>

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

Calls C++ function: [constructor] void QTextDocumentWriter::QTextDocumentWriter(QIODevice* device, const QByteArray& format).

C++ documentation:

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

source

pub unsafe fn from_q_string_q_byte_array( file_name: impl CastInto<Ref<QString>>, format: impl CastInto<Ref<QByteArray>> ) -> CppBox<QTextDocumentWriter>

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.

Calls C++ function: [constructor] void QTextDocumentWriter::QTextDocumentWriter(const QString& fileName, const QByteArray& format = …).

C++ documentation:

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.

source

pub unsafe fn from_q_string( file_name: impl CastInto<Ref<QString>> ) -> CppBox<QTextDocumentWriter>

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.

Calls C++ function: [constructor] void QTextDocumentWriter::QTextDocumentWriter(const QString& fileName).

C++ documentation:

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.

source

pub unsafe fn set_codec(&self, codec: impl CastInto<Ptr<QTextCodec>>)

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.

Calls C++ function: void QTextDocumentWriter::setCodec(QTextCodec* codec).

C++ documentation:

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().

source

pub unsafe fn set_device(&self, device: impl CastInto<Ptr<QIODevice>>)

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.

Calls C++ function: void QTextDocumentWriter::setDevice(QIODevice* device).

C++ documentation:

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().

source

pub unsafe fn set_file_name(&self, file_name: impl CastInto<Ref<QString>>)

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.

Calls C++ function: void QTextDocumentWriter::setFileName(const QString& fileName).

C++ documentation:

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().

source

pub unsafe fn set_format(&self, format: impl CastInto<Ref<QByteArray>>)

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

Calls C++ function: void QTextDocumentWriter::setFormat(const QByteArray& format).

C++ documentation:

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().

source

pub unsafe fn supported_document_formats() -> CppBox<QListOfQByteArray>

Returns the list of document formats supported by QTextDocumentWriter.

Calls C++ function: static QList<QByteArray> QTextDocumentWriter::supportedDocumentFormats().

C++ documentation:

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().

source

pub unsafe fn write_q_text_document( &self, document: impl CastInto<Ptr<QTextDocument>> ) -> bool

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

Calls C++ function: bool QTextDocumentWriter::write(const QTextDocument* document).

C++ documentation:

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

source

pub unsafe fn write_q_text_document_fragment( &self, fragment: impl CastInto<Ref<QTextDocumentFragment>> ) -> bool

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

Calls C++ function: bool QTextDocumentWriter::write(const QTextDocumentFragment& fragment).

C++ documentation:

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

Trait Implementations§

source§

impl CppDeletable for QTextDocumentWriter

source§

unsafe fn delete(&self)

Destroys the QTextDocumentWriter object.

Calls C++ function: [destructor] void QTextDocumentWriter::~QTextDocumentWriter().

C++ documentation:

Destroys the QTextDocumentWriter object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.