class QPdfView#

A PDF viewer widget. More

Inheritance diagram of PySide6.QtPdfWidgets.QPdfView

Synopsis#

Properties#

Methods#

Slots#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QPdfView is a PDF viewer widget that offers a user experience similar to many common PDF viewer applications, with two modes . In the MultiPage mode, it supports flicking through the pages in the entire document, with narrow gaps between the page images. In the SinglePage mode, it shows one page at a time.

class PageMode#

This enum describes the overall behavior of the PDF viewer:

Constant

Description

QPdfView.PageMode.SinglePage

Show one page at a time.

QPdfView.PageMode.MultiPage

Allow scrolling through all pages in the document.

class ZoomMode#

This enum describes the magnification behavior of the PDF viewer:

Constant

Description

QPdfView.ZoomMode.Custom

Use zoomFactor only.

QPdfView.ZoomMode.FitToWidth

Automatically choose a zoom factor so that the width of the page fits in the view.

QPdfView.ZoomMode.FitInView

Automatically choose a zoom factor so that the entire page fits in the view.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property currentSearchResultIndexᅟ: int#

If this property is set to a positive number, and searchModel is set, QPdfView draws a frame around the search result provided by QPdfSearchModel at the given index. For example, if QPdfSearchModel is used as the model for a QListView, you can keep this property updated by connecting QItemSelectionModel::currentChanged() from QListView::selectionModel() to a function that will in turn call this function.

By default it is -1, so that no search results are framed.

Access functions:
property documentᅟ: QPdfDocument#

This property holds the document to be viewed.

Access functions:
property documentMarginsᅟ: QMargins#

This property holds the margins around the page view.

Access functions:
property pageModeᅟ: QPdfView.PageMode#

This property holds whether to show one page at a time, or all pages in the document. The default is SinglePage.

Access functions:
property pageSpacingᅟ: int#

This property holds the size of the padding between pages in the MultiPage mode .

Access functions:
property searchModelᅟ: QPdfSearchModel#

If this property is set, QPdfView draws highlight rectangles over the search results provided by resultsOnPage() . By default it is nullptr.

Access functions:
property zoomFactorᅟ: float#

This property holds the ratio of pixels to points. The default is 1, meaning one point (1/72 of an inch) equals 1 logical pixel.

Access functions:
property zoomModeᅟ: QPdfView.ZoomMode#

This property indicates whether to use a custom size for the page(s), or zoom them to fit to the view. The default is CustomZoom.

Access functions:
__init__(parent)#
Parameters:

parentQWidget

Constructs a PDF viewer with parent widget parent.

__init__()
currentSearchResultIndex()#
Return type:

int

Getter of property currentSearchResultIndexᅟ .

currentSearchResultIndexChanged(currentResult)#
Parameters:

currentResult – int

Notification signal of property currentSearchResultIndexᅟ .

document()#
Return type:

QPdfDocument

See also

setDocument()

Getter of property documentᅟ .

documentChanged(document)#
Parameters:

documentQPdfDocument

Notification signal of property documentᅟ .

documentMargins()#
Return type:

QMargins

Getter of property documentMarginsᅟ .

documentMarginsChanged(documentMargins)#
Parameters:

documentMarginsQMargins

Notification signal of property documentMarginsᅟ .

pageMode()#
Return type:

PageMode

See also

setPageMode()

Getter of property pageModeᅟ .

pageModeChanged(pageMode)#
Parameters:

pageModePageMode

Notification signal of property pageModeᅟ .

pageNavigator()#
Return type:

QPdfPageNavigator

This accessor returns the navigation stack that will handle back/forward navigation.

pageSpacing()#
Return type:

int

See also

setPageSpacing()

Getter of property pageSpacingᅟ .

pageSpacingChanged(pageSpacing)#
Parameters:

pageSpacing – int

Notification signal of property pageSpacingᅟ .

searchModel()#
Return type:

QPdfSearchModel

See also

setSearchModel()

Getter of property searchModelᅟ .

searchModelChanged(searchModel)#
Parameters:

searchModelQPdfSearchModel

Notification signal of property searchModelᅟ .

setCurrentSearchResultIndex(currentResult)#
Parameters:

currentResult – int

Setter of property currentSearchResultIndexᅟ .

setDocument(document)#
Parameters:

documentQPdfDocument

See also

document()

Setter of property documentᅟ .

setDocumentMargins(margins)#
Parameters:

marginsQMargins

Setter of property documentMarginsᅟ .

setPageMode(mode)#
Parameters:

modePageMode

See also

pageMode()

Setter of property pageModeᅟ .

setPageSpacing(spacing)#
Parameters:

spacing – int

See also

pageSpacing()

Setter of property pageSpacingᅟ .

setSearchModel(searchModel)#
Parameters:

searchModelQPdfSearchModel

See also

searchModel()

Setter of property searchModelᅟ .

setZoomFactor(factor)#
Parameters:

factor – float

See also

zoomFactor()

Setter of property zoomFactorᅟ .

setZoomMode(mode)#
Parameters:

modeZoomMode

See also

zoomMode()

Setter of property zoomModeᅟ .

zoomFactor()#
Return type:

float

See also

setZoomFactor()

Getter of property zoomFactorᅟ .

zoomFactorChanged(zoomFactor)#
Parameters:

zoomFactor – float

Notification signal of property zoomFactorᅟ .

zoomMode()#
Return type:

ZoomMode

See also

setZoomMode()

Getter of property zoomModeᅟ .

zoomModeChanged(zoomMode)#
Parameters:

zoomModeZoomMode

Notification signal of property zoomModeᅟ .