TextDocumentWriter
Qt Base Class: QTextDocumentWriter
Signature: QTextDocumentWriter(self) -> None
QTextDocumentWriter(self, device: PySide6.QtCore.QIODevice, format: Union[PySide6.QtCore.QByteArray, bytes]) -> None
QTextDocumentWriter(self, fileName: str, format: Union[PySide6.QtCore.QByteArray, bytes] = Default(QByteArray)) -> None
Base classes
⋔ Inheritance diagram
graph TD
1473245556288["gui.TextDocumentWriter"]
1473245489920["QtGui.QTextDocumentWriter"]
1473291690208["Shiboken.Object"]
140713234304496["builtins.object"]
1473245489920 --> 1473245556288
1473291690208 --> 1473245489920
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: QTextDocumentWriter
Source code in prettyqt\gui\textdocumentwriter.py
| class TextDocumentWriter(QtGui.QTextDocumentWriter):
def __repr__(self):
return get_repr(self, self.device(), self.format())
def get_format(self) -> FormatStr:
return self.format().data().decode() # type: ignore
def set_format(self, fmt: FormatStr | bytes | core.QByteArray):
new = fmt.encode() if isinstance(fmt, str) else fmt
self.setFormat(new)
def set_file_name(self, name: datatypes.PathType):
path = name if isinstance(name, str) else os.fspath(name)
self.setFileName(path)
@classmethod
def get_supported_document_formats(cls) -> list[str]:
return [i.data().decode() for i in cls.supportedDocumentFormats()]
@classmethod
def serialize_document(
cls,
document: QtGui.QTextDocument,
fmt: FormatStr | bytes | core.QByteArray = "ODF",
) -> bytes:
buffer = core.Buffer()
writer = cls()
writer.setDevice(buffer)
writer.set_format(fmt) # ODF Format
writer.write(document)
return buffer.data().data()
|