Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPrintPreviewWidget Class

TheQPrintPreviewWidget class provides a widget for previewing page layouts for printer output.More...

Header:#include <QPrintPreviewWidget>
Since: Qt 4.4
Inherits:QWidget

Public Types

enumViewMode { SinglePageView, FacingPagesView, AllPagesView }
enumZoomMode { CustomZoom, FitToWidth, FitInView }

Public Functions

QPrintPreviewWidget(QPrinter * printer, QWidget * parent = 0, Qt::WindowFlags flags = 0)
QPrintPreviewWidget(QWidget * parent = 0, Qt::WindowFlags flags = 0)
~QPrintPreviewWidget()
intcurrentPage() const
QPrinter::Orientationorientation() const
intpageCount() const
ViewModeviewMode() const
qrealzoomFactor() const
ZoomModezoomMode() const

Reimplemented Public Functions

virtual voidsetVisible(bool visible)

Public Slots

voidfitInView()
voidfitToWidth()
voidprint()
voidsetAllPagesViewMode()
voidsetCurrentPage(int page)
voidsetFacingPagesViewMode()
voidsetLandscapeOrientation()
voidsetOrientation(QPrinter::Orientation orientation)
voidsetPortraitOrientation()
voidsetSinglePageViewMode()
voidsetViewMode(ViewMode mode)
voidsetZoomFactor(qreal factor)
voidsetZoomMode(ZoomMode zoomMode)
voidupdatePreview()
voidzoomIn(qreal factor = 1.1)
voidzoomOut(qreal factor = 1.1)
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidpaintRequested(QPrinter * printer)
voidpreviewChanged()

Additional Inherited Members

  • 58 properties inherited fromQWidget
  • 1 property inherited fromQObject
  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice
  • 1 protected slot inherited fromQWidget

Detailed Description

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:

  1. Create theQPrintPreviewWidget

    Construct theQPrintPreviewWidget either by passing in an existingQPrinter object, or haveQPrintPreviewWidget create a default constructedQPrinter object for you.

  2. Connect thepaintRequested() signal to a slot.

    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.

Member Type Documentation

enum QPrintPreviewWidget::ViewMode

This enum is used to describe the view mode of the preview widget.

ConstantValueDescription
QPrintPreviewWidget::SinglePageView0A mode where single pages in the preview is viewed.
QPrintPreviewWidget::FacingPagesView1A mode where the facing pages in the preview is viewed.
QPrintPreviewWidget::AllPagesView2A view mode where all the pages in the preview is viewed.

enum QPrintPreviewWidget::ZoomMode

This enum is used to describe zoom mode of the preview widget.

ConstantValueDescription
QPrintPreviewWidget::CustomZoom0The zoom is set to a custom zoom value.
QPrintPreviewWidget::FitToWidth1This mode fits the current page to the width of the view.
QPrintPreviewWidget::FitInView2This mode fits the current page inside the view.

Member Function Documentation

QPrintPreviewWidget::QPrintPreviewWidget(QPrinter * printer,QWidget * parent = 0,Qt::WindowFlags flags = 0)

Constructs aQPrintPreviewWidget based onprinter and withparent as the parent widget. The widget flagsflags are passed on to theQWidget constructor.

See alsoQWidget::setWindowFlags().

QPrintPreviewWidget::QPrintPreviewWidget(QWidget * parent = 0,Qt::WindowFlags flags = 0)

This is an overloaded function.

This will causeQPrintPreviewWidget to create an internal, default constructedQPrinter object, which will be used to generate the preview.

QPrintPreviewWidget::~QPrintPreviewWidget()

Destroys theQPrintPreviewWidget.

int QPrintPreviewWidget::currentPage() const

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

QPrinter::Orientation QPrintPreviewWidget::orientation() const

Returns the current orientation of the preview. This value is obtained from theQPrinter object associated with the preview.

See alsosetOrientation().

int QPrintPreviewWidget::pageCount() const

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.

ViewMode QPrintPreviewWidget::viewMode() const

Returns the current view mode. The default view mode isSinglePageView.

See alsosetViewMode().

qreal QPrintPreviewWidget::zoomFactor() const

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

ZoomMode QPrintPreviewWidget::zoomMode() const

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.


[8]ページ先頭

©2009-2025 Movatter.jp