QPageRanges Class

QPageRanges 类表示页面范围集合。更多

头文件: #include <QPageRanges>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Qt 6.0

公共类型

struct Range

公共函数

QPageRanges()
QPageRanges(const QPageRanges &other)
QPageRanges(QPageRanges &&other)
~QPageRanges()
void addPage(int pageNumber)
void addRange(int from, int to)
void clear()
bool contains(int pageNumber) const
int firstPage() const
bool isEmpty() const
int lastPage() const
QList<QPageRanges::Range> toRangeList() const
QString toString() const
QPageRanges &operator=(QPageRanges &&other)
QPageRanges &operator=(const QPageRanges &other)

静态公共成员

QPageRanges fromString(const QString &ranges)
QDataStream &operator<<(QDataStream &stream, const QPageRanges &pageRanges)
QDataStream &operator>>(QDataStream &stream, QPageRanges &pageRanges)

详细说明

使用QPagedPaintDevice::pageRanges() 访问与分页设备相关的页面范围集合。

成员函数文档

QPageRanges::QPageRanges()

构造一个空的 QPageRanges 对象。

[noexcept] QPageRanges::QPageRanges(const QPageRanges &other)

通过复制other 构建一个 QPageRanges 对象。

[noexcept] QPageRanges::QPageRanges(QPageRanges &&other)

other 开始,构造一个 QPageRanges 对象。

[noexcept] QPageRanges::~QPageRanges()

销毁页面范围。

void QPageRanges::addPage(int pageNumber)

将单页pageNumber 添加到范围中。

注意: 页码以 1 开头,添加小于 1 的页码将被忽略并发出警告。

void QPageRanges::addRange(int from, int to)

fromto 指定的范围添加到范围中。

注意: 页码以 1 开头,添加小于 1 的页码将被忽略并发出警告。

void QPageRanges::clear()

删除所有页面范围。

bool QPageRanges::contains(int pageNumber) const

如果范围包括页面pageNumber ,则返回true ;否则返回false

int QPageRanges::firstPage() const

返回页面范围覆盖的第一个页面的索引,如果页面范围为空,则返回 0。

[static] QPageRanges QPageRanges::fromString(const QString &ranges)

构造并返回一个QPageRanges 对象,其中包含字符串表示中的ranges

QPrinter printer;
QPageRanges ranges = QPageRanges::fromString("1-3,6-7");
printer.setPageRanges(ranges);

如果解析错误,则返回一个空的QPageRanges 对象。

另请参见 isEmpty()。

bool QPageRanges::isEmpty() const

如果范围为空,则返回true ;否则返回false

int QPageRanges::lastPage() const

返回页面范围覆盖的最后一页的索引,如果页面范围为空,则返回 0。

QList<QPageRanges::Range> QPageRanges::toRangeList() const

返回包含范围值的列表。

QString QPageRanges::toString() const

返回页面范围的字符串表示。

[noexcept] QPageRanges &QPageRanges::operator=(QPageRanges &&other)

other 移入此QPageRanges 对象。

[noexcept] QPageRanges &QPageRanges::operator=(const QPageRanges &other)

QPageRanges 对象指定other

相关非会员

QDataStream &operator<<(QDataStream &stream, const QPageRanges &pageRanges)

pageRanges 作为范围字符串写入stream

另请参阅 QPageRanges::toString

QDataStream &operator>>(QDataStream &stream, QPageRanges &pageRanges)

stream 读取页面范围字符串,并将其存储在pageRanges 中。

另请参见 QPageRanges::fromString

© 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.