Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPdfView Class Reference

\inmodule QtPdf More...

#include <qpdfview.h>

+ Inheritance diagram for QPdfView:
+ Collaboration diagram for QPdfView:

Public Types

enum class  PageMode { SinglePage , MultiPage }
 This enum describes the overall behavior of the PDF viewer: More...
 
enum class  ZoomMode { Custom , FitToWidth , FitInView }
 This enum describes the magnification behavior of the PDF viewer: More...
 

Public Slots

void setPageMode (QPdfView::PageMode mode)
 
void setZoomMode (QPdfView::ZoomMode mode)
 
void setZoomFactor (qreal factor)
 
void setCurrentSearchResultIndex (int currentResult)
 

Signals

void documentChanged (QPdfDocument *document)
 
void pageModeChanged (QPdfView::PageMode pageMode)
 
void zoomModeChanged (QPdfView::ZoomMode zoomMode)
 
void zoomFactorChanged (qreal zoomFactor)
 
void pageSpacingChanged (int pageSpacing)
 
void documentMarginsChanged (QMargins documentMargins)
 
void searchModelChanged (QPdfSearchModel *searchModel)
 
void currentSearchResultIndexChanged (int currentResult)
 

Public Member Functions

 QPdfView ()
 
 QPdfView (QWidget *parent)
 Constructs a PDF viewer with parent widget parent.
 
 ~QPdfView ()
 Destroys the PDF viewer.
 
void setDocument (QPdfDocument *document)
 
QPdfDocumentdocument () const
 
QPdfSearchModelsearchModel () const
 
void setSearchModel (QPdfSearchModel *searchModel)
 
int currentSearchResultIndex () const
 
QPdfPageNavigatorpageNavigator () const
 This accessor returns the navigation stack that will handle back/forward navigation.
 
PageMode pageMode () const
 
ZoomMode zoomMode () const
 
qreal zoomFactor () const
 
int pageSpacing () const
 
void setPageSpacing (int spacing)
 
QMargins documentMargins () const
 
void setDocumentMargins (QMargins margins)
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void scrollContentsBy (int dx, int dy) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 

Properties

QPdfDocumentdocument
 This property holds the document to be viewed.
 
PageMode pageMode
 This property holds whether to show one page at a time, or all pages in the document.
 
ZoomMode zoomMode
 This property indicates whether to use a custom size for the page(s), or zoom them to fit to the view.
 
qreal zoomFactor
 This property holds the ratio of pixels to points.
 
int pageSpacing
 This property holds the size of the padding between pages in the \l MultiPage \l {pageMode}{mode}.
 
QMargins documentMargins
 This property holds the margins around the page view.
 
QPdfSearchModelsearchModel
 
int currentSearchResultIndex
 

Detailed Description

\inmodule QtPdf

A PDF viewer widget.

QPdfView is a PDF viewer widget that offers a user experience similar to many common PDF viewer applications, with two \l {pageMode}{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.

Definition at line 18 of file qpdfview.h.

Member Enumeration Documentation

◆ PageMode

enum class QPdfView::PageMode
strong

This enum describes the overall behavior of the PDF viewer:

\value SinglePage Show one page at a time. \value MultiPage Allow scrolling through all pages in the document.

Enumerator
SinglePage 
MultiPage 

Definition at line 35 of file qpdfview.h.

◆ ZoomMode

enum class QPdfView::ZoomMode
strong

This enum describes the magnification behavior of the PDF viewer:

\value Custom Use \l zoomFactor only. \value FitToWidth Automatically choose a zoom factor so that the width of the page fits in the view. \value FitInView Automatically choose a zoom factor so that the entire page fits in the view.

Enumerator
Custom 
FitToWidth 
FitInView 

Definition at line 42 of file qpdfview.h.

Constructor & Destructor Documentation

◆ QPdfView() [1/2]

QPdfView::QPdfView ( )
inline

Definition at line 50 of file qpdfview.h.

◆ QPdfView() [2/2]

QPdfView::QPdfView ( QWidget * parent)
explicit

Constructs a PDF viewer with parent widget parent.

Definition at line 294 of file qpdfview.cpp.

◆ ~QPdfView()

QPdfView::~QPdfView ( )

Destroys the PDF viewer.

Definition at line 319 of file qpdfview.cpp.

Member Function Documentation

◆ currentSearchResultIndex()

int QPdfView::currentSearchResultIndex ( ) const

Definition at line 416 of file qpdfview.cpp.

◆ currentSearchResultIndexChanged

void QPdfView::currentSearchResultIndexChanged ( int currentResult)
signal

◆ document()

QPdfDocument * QPdfView::document ( ) const

Definition at line 352 of file qpdfview.cpp.

◆ documentChanged

void QPdfView::documentChanged ( QPdfDocument * document)
signal

◆ documentMargins()

QMargins QPdfView::documentMargins ( ) const

Definition at line 562 of file qpdfview.cpp.

◆ documentMarginsChanged

void QPdfView::documentMarginsChanged ( QMargins documentMargins)
signal

◆ mouseMoveEvent()

void QPdfView::mouseMoveEvent ( QMouseEvent * event)
overrideprotected

Definition at line 670 of file qpdfview.cpp.

◆ mousePressEvent()

void QPdfView::mousePressEvent ( QMouseEvent * event)
overrideprotected

Definition at line 665 of file qpdfview.cpp.

◆ mouseReleaseEvent()

void QPdfView::mouseReleaseEvent ( QMouseEvent * event)
overrideprotected

Definition at line 689 of file qpdfview.cpp.

◆ pageMode()

QPdfView::PageMode QPdfView::pageMode ( ) const

Definition at line 447 of file qpdfview.cpp.

◆ pageModeChanged

void QPdfView::pageModeChanged ( QPdfView::PageMode pageMode)
signal

◆ pageNavigator()

QPdfPageNavigator * QPdfView::pageNavigator ( ) const

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

Definition at line 425 of file qpdfview.cpp.

◆ pageSpacing()

int QPdfView::pageSpacing ( ) const

Definition at line 537 of file qpdfview.cpp.

◆ pageSpacingChanged

void QPdfView::pageSpacingChanged ( int pageSpacing)
signal

◆ paintEvent()

void QPdfView::paintEvent ( QPaintEvent * event)
overrideprotected

Definition at line 582 of file qpdfview.cpp.

◆ resizeEvent()

void QPdfView::resizeEvent ( QResizeEvent * event)
overrideprotected

Definition at line 646 of file qpdfview.cpp.

◆ scrollContentsBy()

void QPdfView::scrollContentsBy ( int dx,
int dy )
overrideprotected

Definition at line 656 of file qpdfview.cpp.

◆ searchModel()

QPdfSearchModel * QPdfView::searchModel ( ) const

Definition at line 386 of file qpdfview.cpp.

◆ searchModelChanged

void QPdfView::searchModelChanged ( QPdfSearchModel * searchModel)
signal

◆ setCurrentSearchResultIndex

void QPdfView::setCurrentSearchResultIndex ( int currentResult)
slot

Definition at line 405 of file qpdfview.cpp.

◆ setDocument()

void QPdfView::setDocument ( QPdfDocument * document)

Definition at line 328 of file qpdfview.cpp.

◆ setDocumentMargins()

void QPdfView::setDocumentMargins ( QMargins margins)

Definition at line 569 of file qpdfview.cpp.

◆ setPageMode

void QPdfView::setPageMode ( QPdfView::PageMode mode)
slot

Definition at line 454 of file qpdfview.cpp.

◆ setPageSpacing()

void QPdfView::setPageSpacing ( int spacing)

Definition at line 544 of file qpdfview.cpp.

◆ setSearchModel()

void QPdfView::setSearchModel ( QPdfSearchModel * searchModel)

Definition at line 367 of file qpdfview.cpp.

◆ setZoomFactor

void QPdfView::setZoomFactor ( qreal factor)
slot

Definition at line 518 of file qpdfview.cpp.

◆ setZoomMode

void QPdfView::setZoomMode ( QPdfView::ZoomMode mode)
slot

Definition at line 492 of file qpdfview.cpp.

◆ zoomFactor()

qreal QPdfView::zoomFactor ( ) const

Definition at line 511 of file qpdfview.cpp.

◆ zoomFactorChanged

void QPdfView::zoomFactorChanged ( qreal zoomFactor)
signal

◆ zoomMode()

QPdfView::ZoomMode QPdfView::zoomMode ( ) const

Definition at line 485 of file qpdfview.cpp.

◆ zoomModeChanged

void QPdfView::zoomModeChanged ( QPdfView::ZoomMode zoomMode)
signal

Property Documentation

◆ currentSearchResultIndex

QPdfView::currentSearchResultIndex
readwrite
Since
6.6

If this property is set to a positive number, and \l searchModel is set, QPdfView draws a frame around the search result provided by \l 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.

Definition at line 32 of file qpdfview.h.

◆ document

QPdfView::document
readwrite

This property holds the document to be viewed.

Definition at line 22 of file qpdfview.h.

◆ documentMargins

QPdfView::documentMargins
readwrite

This property holds the margins around the page view.

Definition at line 29 of file qpdfview.h.

◆ pageMode

QPdfView::pageMode
readwrite

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

The default is SinglePage.

Definition at line 24 of file qpdfview.h.

◆ pageSpacing

QPdfView::pageSpacing
readwrite

This property holds the size of the padding between pages in the \l MultiPage \l {pageMode}{mode}.

Definition at line 28 of file qpdfview.h.

◆ searchModel

QPdfView::searchModel
readwrite
Since
6.6

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

Definition at line 31 of file qpdfview.h.

◆ zoomFactor

QPdfView::zoomFactor
readwrite

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.

Definition at line 26 of file qpdfview.h.

◆ zoomMode

QPdfView::zoomMode
readwrite

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.

Definition at line 25 of file qpdfview.h.


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