
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPrintPreviewWidget class provides a widget for previewing page layouts for printer output.More...
| Header: | #include <QPrintPreviewWidget> |
| Since: | Qt 4.4 |
| Inherits: | QWidget |
| enum | ViewMode { SinglePageView, FacingPagesView, AllPagesView } |
| enum | ZoomMode { CustomZoom, FitToWidth, FitInView } |
| QPrintPreviewWidget(QPrinter * printer, QWidget * parent = 0, Qt::WindowFlags flags = 0) | |
| QPrintPreviewWidget(QWidget * parent = 0, Qt::WindowFlags flags = 0) | |
| ~QPrintPreviewWidget() | |
| int | currentPage() const |
| QPrinter::Orientation | orientation() const |
| int | pageCount() const |
| ViewMode | viewMode() const |
| qreal | zoomFactor() const |
| ZoomMode | zoomMode() const |
| virtual void | setVisible(bool visible) |
| void | fitInView() |
| void | fitToWidth() |
| void | print() |
| void | setAllPagesViewMode() |
| void | setCurrentPage(int page) |
| void | setFacingPagesViewMode() |
| void | setLandscapeOrientation() |
| void | setOrientation(QPrinter::Orientation orientation) |
| void | setPortraitOrientation() |
| void | setSinglePageViewMode() |
| void | setViewMode(ViewMode mode) |
| void | setZoomFactor(qreal factor) |
| void | setZoomMode(ZoomMode zoomMode) |
| void | updatePreview() |
| void | zoomIn(qreal factor = 1.1) |
| void | zoomOut(qreal factor = 1.1) |
| void | paintRequested(QPrinter * printer) |
| void | previewChanged() |
TheQPrintPreviewWidget class provides a widget for previewing page layouts for printer output.
QPrintPreviewDialog uses aQPrintPreviewWidget internally, and the purpose ofQPrintPreviewWidget is 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 withQPrintPreviewDialog.
UsingQPrintPreviewWidget is straightforward:
Construct theQPrintPreviewWidget either by passing in an existingQPrinter object, or haveQPrintPreviewWidget create a default constructedQPrinter object for you.
When the widget needs to generate a set of preview pages, apaintRequested() signal will be emitted from the widget. Connect a slot to this signal, and draw onto theQPrinter passed in as a signal parameter. CallQPrinter::newPage(), to start a new page in the preview.
See alsoQPrinter,QPrintDialog,QPageSetupDialog, andQPrintPreviewDialog.
This enum is used to describe the view mode of the preview widget.
| Constant | Value | Description |
|---|---|---|
QPrintPreviewWidget::SinglePageView | 0 | A mode where single pages in the preview is viewed. |
QPrintPreviewWidget::FacingPagesView | 1 | A mode where the facing pages in the preview is viewed. |
QPrintPreviewWidget::AllPagesView | 2 | A view mode where all the pages in the preview is viewed. |
This enum is used to describe zoom mode of the preview widget.
| Constant | Value | Description |
|---|---|---|
QPrintPreviewWidget::CustomZoom | 0 | The zoom is set to a custom zoom value. |
QPrintPreviewWidget::FitToWidth | 1 | This mode fits the current page to the width of the view. |
QPrintPreviewWidget::FitInView | 2 | This mode fits the current page inside the view. |
Constructs aQPrintPreviewWidget based onprinter and withparent as the parent widget. The widget flagsflags are passed on to theQWidget constructor.
See alsoQWidget::setWindowFlags().
This is an overloaded function.
This will causeQPrintPreviewWidget to create an internal, default constructedQPrinter object, which will be used to generate the preview.
Destroys theQPrintPreviewWidget.
Returns the currently viewed page in the preview.
See alsosetCurrentPage().
[slot]void QPrintPreviewWidget::fitInView()This is a convenience function and is the same as callingsetZoomMode(QPrintPreviewWidget::FitInView).
[slot]void QPrintPreviewWidget::fitToWidth()This is a convenience function and is the same as callingsetZoomMode(QPrintPreviewWidget::FitToWidth).
Returns the current orientation of the preview. This value is obtained from theQPrinter object associated with the preview.
See alsosetOrientation().
Returns the number of pages in the preview.
This function was introduced in Qt 4.6.
[signal]void QPrintPreviewWidget::paintRequested(QPrinter * printer)This signal is emitted when the preview widget needs to generate a set of preview pages.printer is the printer associated with this preview widget.
[signal]void QPrintPreviewWidget::previewChanged()This signal is emitted whenever the preview widget has changed some internal state, such as the orientation.
[slot]void QPrintPreviewWidget::print()Prints the preview to the printer associated with the preview.
[slot]void QPrintPreviewWidget::setAllPagesViewMode()This is a convenience function and is the same as callingsetViewMode(QPrintPreviewWidget::AllPagesView).
[slot]void QPrintPreviewWidget::setCurrentPage(int page)Sets the current page in the preview. This will cause the view to skip to the beginning ofpage.
See alsocurrentPage().
[slot]void QPrintPreviewWidget::setFacingPagesViewMode()This is a convenience function and is the same as callingsetViewMode(QPrintPreviewWidget::FacingPagesView).
[slot]void QPrintPreviewWidget::setLandscapeOrientation()This is a convenience function and is the same as callingsetOrientation(QPrinter::Landscape).
[slot]void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation)Sets the current orientation toorientation. This value will be set on theQPrinter object associated with the preview.
See alsoorientation().
[slot]void QPrintPreviewWidget::setPortraitOrientation()This is a convenience function and is the same as callingsetOrientation(QPrinter::Portrait).
[slot]void QPrintPreviewWidget::setSinglePageViewMode()This is a convenience function and is the same as callingsetViewMode(QPrintPreviewWidget::SinglePageView).
[slot]void QPrintPreviewWidget::setViewMode(ViewMode mode)Sets the view mode tomode. The default view mode isSinglePageView.
See alsoviewMode().
[virtual]void QPrintPreviewWidget::setVisible(bool visible)Reimplemented fromQWidget::setVisible().
[slot]void QPrintPreviewWidget::setZoomFactor(qreal factor)Sets the zoom factor of the view tofactor. 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 alsozoomFactor().
[slot]void QPrintPreviewWidget::setZoomMode(ZoomMode zoomMode)Sets the zoom mode tozoomMode. The default zoom mode isFitInView.
See alsozoomMode(),viewMode(), andsetViewMode().
[slot]void QPrintPreviewWidget::updatePreview()This function updates the preview, which causes thepaintRequested() signal to be emitted.
Returns the current view mode. The default view mode isSinglePageView.
See alsosetViewMode().
Returns the zoom factor of the view.
See alsosetZoomFactor().
[slot]void QPrintPreviewWidget::zoomIn(qreal factor = 1.1)Zooms the current view in byfactor. The default value forfactor is 1.1, which means the view will be scaled up by 10%.
Returns the current zoom mode.
See alsosetZoomMode(),viewMode(), andsetViewMode().
[slot]void QPrintPreviewWidget::zoomOut(qreal factor = 1.1)Zooms the current view out byfactor. The default value forfactor is 1.1, which means the view will be scaled down by 10%.
© 2016 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 theGNU 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.