Skip to content

PdfBookmarkModel

Base classes

Name Children Inherits
AbstractItemModelMixin
prettyqt.core.abstractitemmodel
QPdfBookmarkModel
PySide6.QtPdf
QPdfBookmarkModel(self, parent: PySide6.QtCore.QObject, /, *, document: PySide6.QtPdf.QPdfDocument | None \= None) -> None

⋔ Inheritance diagram

graph TD
  3668871686["pdf.PdfBookmarkModel"]
  3882849576["core.AbstractItemModelMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  157547216["QtPdf.QPdfBookmarkModel"]
  1898060022["QtCore.QAbstractItemModel"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  3882849576 --> 3668871686
  3227531497 --> 3882849576
  2751680898 --> 3227531497
  2751680898 --> 3882849576
  157547216 --> 3668871686
  1898060022 --> 157547216
  3984060476 --> 1898060022
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: AbstractItemModelMixin, QPdfBookmarkModel

Holds a tree of of links within a PDF document, such as the table of contents.

Source code in prettyqt/pdf/pdfbookmarkmodel.py
class PdfBookmarkModel(core.AbstractItemModelMixin, pdf.QPdfBookmarkModel):
    """Holds a tree of of links within a PDF document, such as the table of contents."""

    def __init__(self, parent: core.QObject | None = None):
        super().__init__(parent)
        self.setDocument(pdf.PdfDocument(self))

    def set_document(self, document: datatypes.PathType | pdf.QPdfDocument):
        """Set document for model."""
        if not isinstance(document, pdf.QPdfDocument):
            path = os.fspath(document)
            document = pdf.PdfDocument(self)
            document.load(path)
        self.setDocument(document)

set_document(document: datatypes.PathType | pdf.QPdfDocument)

Set document for model.

Source code in prettyqt/pdf/pdfbookmarkmodel.py
def set_document(self, document: datatypes.PathType | pdf.QPdfDocument):
    """Set document for model."""
    if not isinstance(document, pdf.QPdfDocument):
        path = os.fspath(document)
        document = pdf.PdfDocument(self)
        document.load(path)
    self.setDocument(document)

:fa-brands-github: Show source on GitHub