Qt 6.x
The Qt SDK
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 setCurrentSearchResult (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 currentSearchResultChanged (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 currentSearchResult () 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 currentSearchResult
 

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 20 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 37 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 44 of file qpdfview.h.

Constructor & Destructor Documentation

◆ QPdfView() [1/2]

QPdfView::QPdfView ( )
inline

Definition at line 52 of file qpdfview.h.

◆ QPdfView() [2/2]

QPdfView::QPdfView ( QWidget parent)
explicit

Constructs a PDF viewer with parent widget parent.

Definition at line 280 of file qpdfview.cpp.

◆ ~QPdfView()

QPdfView::~QPdfView ( )

Destroys the PDF viewer.

Definition at line 305 of file qpdfview.cpp.

Member Function Documentation

◆ currentSearchResult()

int QPdfView::currentSearchResult ( ) const

Definition at line 402 of file qpdfview.cpp.

◆ currentSearchResultChanged

void QPdfView::currentSearchResultChanged ( int  currentResult)
signal

◆ document()

QPdfDocument * QPdfView::document ( ) const

Definition at line 338 of file qpdfview.cpp.

◆ documentChanged

void QPdfView::documentChanged ( QPdfDocument document)
signal

◆ documentMargins()

QMargins QPdfView::documentMargins ( ) const

Definition at line 548 of file qpdfview.cpp.

◆ documentMarginsChanged

void QPdfView::documentMarginsChanged ( QMargins  documentMargins)
signal

◆ mouseMoveEvent()

void QPdfView::mouseMoveEvent ( QMouseEvent event)
overrideprotected

Definition at line 656 of file qpdfview.cpp.

◆ mousePressEvent()

void QPdfView::mousePressEvent ( QMouseEvent event)
overrideprotected

Definition at line 651 of file qpdfview.cpp.

◆ mouseReleaseEvent()

void QPdfView::mouseReleaseEvent ( QMouseEvent event)
overrideprotected

Definition at line 674 of file qpdfview.cpp.

◆ pageMode()

QPdfView::PageMode QPdfView::pageMode ( ) const

Definition at line 433 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 411 of file qpdfview.cpp.

◆ pageSpacing()

int QPdfView::pageSpacing ( ) const

Definition at line 523 of file qpdfview.cpp.

◆ pageSpacingChanged

void QPdfView::pageSpacingChanged ( int  pageSpacing)
signal

◆ paintEvent()

void QPdfView::paintEvent ( QPaintEvent event)
overrideprotected

Definition at line 568 of file qpdfview.cpp.

◆ resizeEvent()

void QPdfView::resizeEvent ( QResizeEvent event)
overrideprotected

Definition at line 632 of file qpdfview.cpp.

◆ scrollContentsBy()

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

Definition at line 642 of file qpdfview.cpp.

◆ searchModel()

QPdfSearchModel * QPdfView::searchModel ( ) const

Definition at line 372 of file qpdfview.cpp.

◆ searchModelChanged

void QPdfView::searchModelChanged ( QPdfSearchModel searchModel)
signal

◆ setCurrentSearchResult

void QPdfView::setCurrentSearchResult ( int  currentResult)
slot

Definition at line 391 of file qpdfview.cpp.

◆ setDocument()

void QPdfView::setDocument ( QPdfDocument document)

Definition at line 314 of file qpdfview.cpp.

◆ setDocumentMargins()

void QPdfView::setDocumentMargins ( QMargins  margins)

Definition at line 555 of file qpdfview.cpp.

◆ setPageMode

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

Definition at line 440 of file qpdfview.cpp.

◆ setPageSpacing()

void QPdfView::setPageSpacing ( int  spacing)

Definition at line 530 of file qpdfview.cpp.

◆ setSearchModel()

void QPdfView::setSearchModel ( QPdfSearchModel searchModel)

Definition at line 353 of file qpdfview.cpp.

◆ setZoomFactor

void QPdfView::setZoomFactor ( qreal  factor)
slot

Definition at line 504 of file qpdfview.cpp.

◆ setZoomMode

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

Definition at line 478 of file qpdfview.cpp.

◆ zoomFactor()

qreal QPdfView::zoomFactor ( ) const

Definition at line 497 of file qpdfview.cpp.

◆ zoomFactorChanged

void QPdfView::zoomFactorChanged ( qreal  zoomFactor)
signal

◆ zoomMode()

QPdfView::ZoomMode QPdfView::zoomMode ( ) const

Definition at line 471 of file qpdfview.cpp.

◆ zoomModeChanged

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

Property Documentation

◆ currentSearchResult

QPdfView::currentSearchResult
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 105 of file qpdfview.h.

◆ document

QPdfView::document
readwrite

This property holds the document to be viewed.

Definition at line 105 of file qpdfview.h.

◆ documentMargins

QPdfView::documentMargins
readwrite

This property holds the margins around the page view.

Definition at line 105 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 105 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 105 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 105 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 105 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 105 of file qpdfview.h.


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