- Qt 6.12
- Qt PDF
- C++ Classes
- QPdfLinkModel
- Qt 6.12.0 Reference Documentation

# QPdfLinkModel Class

The QPdfLinkModel class holds the geometry and the destination for each link that the specified page contains. More...

Header: | `#include <QPdfLinkModel>`
Since: | Qt 6.6
Inherits: | QAbstractListModel

- List of all members, including inherited members

## Public Types

enum class | Role { Link, Rectangle, Url, Page, Location, Zoom }

## Properties

- document : QPdfDocument*
- page : int

## Public Functions

| QPdfLinkModel(QObject *parent = nullptr)
virtual | ~QPdfLinkModel() override
QPdfDocument * | document() const
QPdfLink | linkAt(QPointF point) const
int | page() const

## Reimplemented Public Functions

virtual QVariant | data(const QModelIndex &index, int role) const override
virtual int | rowCount(const QModelIndex &parent) const override

## Public Slots

void | setDocument(QPdfDocument *document)
void | setPage(int page)

## Signals

void | documentChanged()
void | pageChanged(int page)

## Detailed Description

This is used in PDF viewers to implement the hyperlink mechanism.

## Member Type Documentation

### enum class QPdfLinkModel::Role

Constant | Value | Description
--- | --- | ---
`QPdfLinkModel::Role::Link` | `Qt::UserRole` | A QPdfLink object.
`QPdfLinkModel::Role::Rectangle` | `257` | Bounding rectangle around the link.
`QPdfLinkModel::Role::Url` | `258` | If the link is a web link, the URL for that; otherwise an empty URL.
`QPdfLinkModel::Role::Page` | `259` | If the link is an internal link, the page number to which the link should jump; otherwise `-1`.
`QPdfLinkModel::Role::Location` | `260` | If the link is an internal link, the location on the page to which the link should jump.
`QPdfLinkModel::Role::Zoom` | `261` | If the link is an internal link, the suggested zoom level on the destination page.

## Property Documentation

### document : QPdfDocument*

This property holds the document to load links from.

Access functions:

QPdfDocument * | document() const
void | setDocument(QPdfDocument *document)

Notifier signal:

void | documentChanged()

### page : int

This property holds the page to load links from.

Access functions:

int | page() const
void | setPage(int page)

Notifier signal:

void | pageChanged(int page)

## Member Function Documentation

### `[explicit]` QPdfLinkModel::QPdfLinkModel(QObject *parent = nullptr)

Constructs a new link model with parent object parent.

### `[override virtual noexcept]` QPdfLinkModel::~QPdfLinkModel()

Destroys the model.

### `[override virtual]` QVariant QPdfLinkModel::data(const QModelIndex &index, int role) const

Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.

### QPdfLink QPdfLinkModel::linkAt(QPointF point) const

Returns a valid link if found under the point (given in units of points, 1/72 of an inch), or an invalid link if it is not found. In other words, this function is useful for picking, to handle mouse click or hover.

### `[override virtual]` int QPdfLinkModel::rowCount(const QModelIndex &parent) const

Reimplements: QAbstractItemModel::rowCount(const QModelIndex &parent) const.