QPdfLinkModel Class

QPdfLinkModel 类保存指定page 所包含的每个链接的几何图形和目的地。更多

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

公共类型

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

属性

公共函数

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

重新实现的公共函数

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

公共插槽

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

信号

void documentChanged()
void pageChanged(int page)

详细说明

在 PDF 阅读器中用于实现超链接机制。

成员类型文档

enum class QPdfLinkModel::Role

常数描述
QPdfLinkModel::Role::LinkQt::UserRoleQPdfLink 对象。
QPdfLinkModel::Role::Rectangle257链接周围的边界矩形。
QPdfLinkModel::Role::Url258如果链接是网络链接,则是该链接的 URL;否则是空 URL。
QPdfLinkModel::Role::Page259如果链接是内部链接,则是链接应跳转到的页码;否则是-1
QPdfLinkModel::Role::Location260如果该链接是内部链接,则表示该链接应跳转到的页面位置。
QPdfLinkModel::Role::Zoom261如果该链接是内部链接,则为目标页面的建议缩放级别。

属性文档

document : QPdfDocument*

该属性用于保存要加载链接的文档。

访问功能:

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

通知信号:

void documentChanged()

page : int

该属性用于保存加载链接的页面。

访问功能:

int page() const
void setPage(int page)

Notifier 信号:

void pageChanged(int page)

成员函数文档

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

构建一个新的链接模型,父对象为parent

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

破坏模型。

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

重实现:QAbstractItemModel::data(const QModelIndex &index, int role) const.

QPdfLink QPdfLinkModel::linkAt(QPointF point) const

如果在point (以点为单位,1/72 英寸)下找到链接,则返回valid 链接;如果没有找到链接,则返回无效链接。换句话说,该函数可用于拾取,处理鼠标点击或悬停。

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

重实现:QAbstractItemModel::rowCount(const QModelIndex &parent) const.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.