PySide6.QtPrintSupport.QPrintPreviewWidget¶
- class QPrintPreviewWidget¶
- The - QPrintPreviewWidgetclass provides a widget for previewing page layouts for printer output. More…- Synopsis¶- Methods¶- def - __init__()
- def - currentPage()
- def - orientation()
- def - pageCount()
- def - viewMode()
- def - zoomFactor()
- def - zoomMode()
 - Slots¶- def - fitInView()
- def - fitToWidth()
- def - print_()
- def - setCurrentPage()
- def - setOrientation()
- def - setViewMode()
- def - setZoomFactor()
- def - setZoomMode()
- def - updatePreview()
- def - zoomIn()
- def - zoomOut()
 - Signals¶- def - paintRequested()
- def - previewChanged()
 - 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¶- QPrintPreviewDialoguses a- QPrintPreviewWidgetinternally, and the purpose of- QPrintPreviewWidgetis to make it possible to embed the preview into other widgets. It also makes it possible to build a different user interface around it than the default one provided with- QPrintPreviewDialog.- Using - QPrintPreviewWidgetis straightforward:- Create the - QPrintPreviewWidget- Construct the - QPrintPreviewWidgeteither by passing in an existing- QPrinterobject, or have- QPrintPreviewWidgetcreate a default constructed- QPrinterobject for you.
- Connect the - paintRequested()signal to a slot.- When the widget needs to generate a set of preview pages, a - paintRequested()signal will be emitted from the widget. Connect a slot to this signal, and draw onto the- QPrinterpassed in as a signal parameter. Call- newPage(), to start a new page in the preview.
 - class ViewMode¶
- This enum is used to describe the view mode of the preview widget. - Constant - Description - QPrintPreviewWidget.SinglePageView - A mode where single pages in the preview is viewed. - QPrintPreviewWidget.FacingPagesView - A mode where the facing pages in the preview is viewed. - QPrintPreviewWidget.AllPagesView - A view mode where all the pages in the preview is viewed. 
 - class ZoomMode¶
- This enum is used to describe zoom mode of the preview widget. - Constant - Description - QPrintPreviewWidget.CustomZoom - The zoom is set to a custom zoom value. - QPrintPreviewWidget.FitToWidth - This mode fits the current page to the width of the view. - QPrintPreviewWidget.FitInView - This mode fits the current page inside the view. 
 - __init__([parent=None[, flags=Qt.WindowFlags()]])¶
- Parameters:
- parent – - QWidget
- flags – Combination of - WindowType
 
 
 - This is an overloaded function. - This will cause - QPrintPreviewWidgetto create an internal, default constructed- QPrinterobject, which will be used to generate the preview.- __init__(printer[, parent=None[, flags=Qt.WindowFlags()]])
- Parameters:
- printer – - QPrinter
- parent – - QWidget
- flags – Combination of - WindowType
 
 
 - Constructs a - QPrintPreviewWidgetbased on- printerand with- parentas the parent widget. The widget flags- flagsare passed on to the QWidget constructor.- See also - currentPage()¶
- Return type:
- int 
 
 - Returns the currently viewed page in the preview. - See also - fitInView()¶
 - This is a convenience function and is the same as calling - setZoomMode(QPrintPreviewWidget::FitInView).- fitToWidth()¶
 - This is a convenience function and is the same as calling - setZoomMode(QPrintPreviewWidget::FitToWidth).- orientation()¶
- Return type:
 
 - Returns the current orientation of the preview. This value is obtained from the - QPrinterobject associated with the preview.- See also - pageCount()¶
- Return type:
- int 
 
 - Returns the number of pages in the preview. - This signal is emitted when the preview widget needs to generate a set of preview pages. - printeris the printer associated with this preview widget.- previewChanged()¶
 - This signal is emitted whenever the preview widget has changed some internal state, such as the orientation. - print_()¶
 - setAllPagesViewMode()¶
 - This is a convenience function and is the same as calling - setViewMode(QPrintPreviewWidget::AllPagesView).- setCurrentPage(pageNumber)¶
- Parameters:
- pageNumber – int 
 
 - Sets the current page in the preview. This will cause the view to skip to the beginning of - page.- See also - setFacingPagesViewMode()¶
 - This is a convenience function and is the same as calling - setViewMode(QPrintPreviewWidget::FacingPagesView).- setLandscapeOrientation()¶
 - This is a convenience function and is the same as calling - setOrientation(QPageLayout::Landscape).- setOrientation(orientation)¶
- Parameters:
- orientation – - Orientation
 
 - Sets the current orientation to - orientation. This value will be set on the- QPrinterobject associated with the preview.- See also - setPortraitOrientation()¶
 - This is a convenience function and is the same as calling - setOrientation(QPageLayout::Portrait).- setSinglePageViewMode()¶
 - This is a convenience function and is the same as calling - setViewMode(QPrintPreviewWidget::SinglePageView).- Sets the view mode to - mode. The default view mode is- SinglePageView.- See also - setZoomFactor(zoomFactor)¶
- Parameters:
- zoomFactor – float 
 
 - Sets the zoom factor of the view to - factor. For example, a value of 1.0 indicates an unscaled view, which is approximately the size the view will have on paper. A value of 0.5 will halve the size of the view, while a value of 2.0 will double the size of the view.- See also - Sets the zoom mode to - zoomMode. The default zoom mode is- FitInView.- See also - updatePreview()¶
 - This function updates the preview, which causes the - paintRequested()signal to be emitted.- Returns the current view mode. The default view mode is - SinglePageView.- See also - zoomFactor()¶
- Return type:
- float 
 
 - Returns the zoom factor of the view. - See also - zoomIn([zoom=1.1])¶
- Parameters:
- zoom – float 
 
 - Zooms the current view in by - factor. The default value for- factoris 1.1, which means the view will be scaled up by 10%.- Returns the current zoom mode. - See also - zoomOut([zoom=1.1])¶
- Parameters:
- zoom – float 
 
 - Zooms the current view out by - factor. The default value for- factoris 1.1, which means the view will be scaled down by 10%.