Navigation history within a PDF document. 更多...
头: | #include <QPdfPageNavigator> |
Since: | Qt 6.4 |
继承: | QObject |
|
|
QPdfPageNavigator (QObject * parent ) | |
virtual | ~QPdfPageNavigator () override |
bool | backAvailable () const |
QPointF | currentLocation () const |
int | currentPage () const |
qreal | currentZoom () const |
bool | forwardAvailable () const |
void | back () |
void | clear () |
void | forward () |
void | jump (QPdfLink destination ) |
void | jump (int page , const QPointF & location , qreal zoom = 0) |
void | update (int page , const QPointF & location , qreal zoom ) |
void | backAvailableChanged (bool available ) |
void | currentLocationChanged (QPointF location ) |
void | currentPageChanged (int page ) |
void | currentZoomChanged (qreal zoom ) |
void | forwardAvailableChanged (bool available ) |
void | jumped (QPdfLink current ) |
The QPdfPageNavigator class remembers which destinations the user has visited in a PDF document, and provides the ability to traverse backward and forward. It is used to implement back and forward actions similar to the back and forward buttons in a web browser.
另请参阅 QPdfDocument .
[read-only]
backAvailable
: const
bool
保持
true
若
back
destination is available in the history: that is, if push() or
forward
() 被调用。
访问函数:
bool | backAvailable () const |
通知程序信号:
void | backAvailableChanged (bool available ) |
[read-only]
currentLocation
: const
QPointF
This property holds the current location on the page that is being viewed (the location that was last given to
jump
() 或
update
()). The default is
0, 0
.
访问函数:
QPointF | currentLocation () const |
通知程序信号:
void | currentLocationChanged (QPointF location ) |
[read-only]
currentPage
: const
int
This property holds the current page that is being viewed. The default is
0
.
访问函数:
int | currentPage () const |
通知程序信号:
void | currentPageChanged (int page ) |
[read-only]
currentZoom
: const
qreal
This property holds the magnification scale (1 logical pixel = 1 point) on the page that is being viewed. The default is
1
.
访问函数:
qreal | currentZoom () const |
通知程序信号:
void | currentZoomChanged (qreal zoom ) |
[read-only]
forwardAvailable
: const
bool
保持
true
若
forward
destination is available in the history: that is, if
back
() has been previously called.
访问函数:
bool | forwardAvailable () const |
通知程序信号:
void | forwardAvailableChanged (bool available ) |
[explicit]
QPdfPageNavigator::
QPdfPageNavigator
(
QObject
*
parent
)
Constructs a page navigation stack with parent object parent .
[override virtual noexcept]
QPdfPageNavigator::
~QPdfPageNavigator
()
Destroys the page navigation stack.
[slot]
void
QPdfPageNavigator::
back
()
Pops the stack, updates the currentPage , currentLocation and currentZoom properties to the most-recently-viewed destination, and then emits the jumped () 信号。
[slot]
void
QPdfPageNavigator::
clear
()
Clear the history and restore currentPage , currentLocation and currentZoom to their default values.
[slot]
void
QPdfPageNavigator::
forward
()
Goes back to the page, location and zoom level that was being viewed before back () was called, and then emits the jumped () 信号。
If a new destination was pushed since the last time back () was called, the forward() function does nothing, because there is a branch in the timeline which causes the "future" to be lost.
[slot]
void
QPdfPageNavigator::
jump
(
QPdfLink
destination
)
添加给定 destination to the history of visited locations.
In this case, PDF views respond to the
jumped
signal by scrolling to place
destination.rectangles
in the viewport, as opposed to placing
destination.location
in the viewport. So it's appropriate to call this method to jump to a search result from
QPdfSearchModel
(because the rectangles cover the region of text found). To jump to a hyperlink destination, call jump(page, location, zoom) instead, because in that case the
QPdfLink
对象的
rectangles
cover the hyperlink origin location rather than the destination.
[slot]
void
QPdfPageNavigator::
jump
(
int
page
, const
QPointF
&
location
,
qreal
zoom
= 0)
Adds the given destination, consisting of page , location ,和 zoom , to the history of visited locations.
The
zoom
argument represents magnification (where
1
is the default scale, 1 logical pixel = 1 point). If
zoom
is not given or is
0
,
currentZoom
keeps its existing value, and
currentZoomChanged
is not emitted.
The location should be the same as QPdfLink::location () if the user is following a link; and since that is specified as the upper-left corner of the destination, it is best for consistency to always use the location visible in the upper-left corner of the viewport, in points.
若
forwardAvailable
is
true
, calling this function represents a branch in the timeline which causes the "future" to be lost, and therefore
forwardAvailable
将改变为
false
.
[signal]
void
QPdfPageNavigator::
jumped
(
QPdfLink
current
)
This signal is emitted when an abrupt jump occurs, to the current page index, location on the page, and zoom level; but not when simply scrolling through the document one page at a time. That is, jump (), forward () 和 back () emit this signal, but update () does not.
若
current.rectangles.length > 0
, they are rectangles that cover a specific destination area: a search result that should be made visible; otherwise,
current.location
is the destination location on the
page
(a hyperlink destination, or during forward/back navigation).
[slot]
void
QPdfPageNavigator::
update
(
int
page
, const
QPointF
&
location
,
qreal
zoom
)
Modifies the current destination, consisting of page , location and zoom .
This can be called periodically while the user is manually moving around the document, so that after back () is called, forward () will jump back to the most-recently-viewed destination rather than the destination that was last specified by push().
The
currentZoomChanged
,
currentPageChanged
and
currentLocationChanged
signals will be emitted if the respective properties are actually changed. The
jumped
signal is not emitted, because this operation represents smooth movement rather than a navigational jump.