class QPageRanges

The QPageRanges class represents a collection of page ranges. More

Synopsis

Methods

Static functions

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

Use pageRanges() to access the collection of page ranges associated with a paged device.

__init__()

Constructs an empty QPageRanges object.

__init__(other)
Parameters:

otherQPageRanges

Constructs a QPageRanges object by copying other.

addPage(pageNumber)
Parameters:

pageNumber – int

Adds the single page pageNumber to the ranges.

Note

Page numbers start with 1. Attempts to add page numbers smaller than 1 will be ignored with a warning.

addRange(from, to)
Parameters:
  • from – int

  • to – int

Adds the range specified with from and to to the ranges.

Note

Page numbers start with 1. Attempts to add page numbers smaller than 1 will be ignored with a warning.

clear()

Removes all page ranges.

contains(pageNumber)
Parameters:

pageNumber – int

Return type:

bool

Returns true if the ranges include the page pageNumber; otherwise returns false.

firstPage()
Return type:

int

Returns the index of the first page covered by the page ranges, or 0 if the page ranges are empty.

static fromString(ranges)
Parameters:

ranges – str

Return type:

QPageRanges

Constructs and returns a QPageRanges object populated with the ranges from the string representation.

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

In case of parsing error, returns an empty QPageRanges object.

See also

isEmpty()

isEmpty()
Return type:

bool

Returns true if the ranges are empty; otherwise returns false.

lastPage()
Return type:

int

Returns the index of the last page covered by the page ranges, or 0 if the page ranges are empty.

__ne__(rhs)
Parameters:

rhsQPageRanges

Return type:

bool

__eq__(rhs)
Parameters:

rhsQPageRanges

Return type:

bool

swap(other)
Parameters:

otherQPageRanges

toRangeList()
Return type:

.list of QPageRanges.Range

Returns a list with the values of the ranges.

toString()
Return type:

str

Returns the string representation of the page ranges.