QPrintPreviewWidgetclass provides a widget for previewing page layouts for printer output. 更多 …
def
currentPage
()
def
orientation
()
def
pageCount
()
def
viewMode
()
def
zoomFactor
()
def
zoomMode
()
def
fitInView
()
def
fitToWidth
()
def
print_
()
def
setAllPagesViewMode
()
def
setCurrentPage
(pageNumber)
def
setFacingPagesViewMode
()
def
setLandscapeOrientation
()
def
setOrientation
(orientation)
def
setPortraitOrientation
()
def
setSinglePageViewMode
()
def
setViewMode
(viewMode)
def
setZoomFactor
(zoomFactor)
def
setZoomMode
(zoomMode)
def
updatePreview
()
def
zoomIn
([zoom=1.1])
def
zoomOut
([zoom=1.1])
def
paintRequested
(printer)
def
previewChanged
()
QPrintPreviewDialoguses aQPrintPreviewWidgetinternally, and the purpose ofQPrintPreviewWidgetis 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.使用
QPrintPreviewWidgetis straightforward:
Create the
QPrintPreviewWidgetConstruct the
QPrintPreviewWidgeteither by passing in an existingQPrinterobject, or haveQPrintPreviewWidgetcreate a default constructedQPrinterobject 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 theQPrinterpassed in as a signal parameter. CallnewPage(), to start a new page in the preview.
QPrintPreviewWidget
(
printer
[
,
parent=None
[
,
flags=Qt.WindowFlags()
]
]
)
¶
QPrintPreviewWidget([parent=None[, flags=Qt.WindowFlags()]])
- param parent
QWidget- param flags
WindowFlags- param printer
构造
QPrintPreviewWidget
基于
printer
和采用
parent
as the parent widget. The widget flags
flags
are passed on to the
QWidget
构造函数。
另请参阅
setWindowFlags()
这是重载函数。
This will cause
QPrintPreviewWidget
to create an internal, default constructed
QPrinter
object, which will be used to generate the preview.
PySide2.QtPrintSupport.QPrintPreviewWidget.
ViewMode
¶
This enum is used to describe the view mode of the preview widget.
|
常量 |
描述 |
|---|---|
|
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. |
PySide2.QtPrintSupport.QPrintPreviewWidget.
ZoomMode
¶
This enum is used to describe zoom mode of the preview widget.
|
常量 |
描述 |
|---|---|
|
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. |
PySide2.QtPrintSupport.QPrintPreviewWidget.
currentPage
(
)
¶
int
Returns the currently viewed page in the preview.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
fitInView
(
)
¶
This is a convenience function and is the same as calling
setZoomMode(QPrintPreviewWidget::FitInView)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
fitToWidth
(
)
¶
This is a convenience function and is the same as calling
setZoomMode(QPrintPreviewWidget::FitToWidth)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
orientation
(
)
¶
取向
Returns the current orientation of the preview. This value is obtained from the
QPrinter
object associated with the preview.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
pageCount
(
)
¶
int
Returns the number of pages in the preview.
PySide2.QtPrintSupport.QPrintPreviewWidget.
previewChanged
(
)
¶
PySide2.QtPrintSupport.QPrintPreviewWidget.
print_
(
)
¶
Prints the preview to the printer associated with the preview.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setAllPagesViewMode
(
)
¶
This is a convenience function and is the same as calling
setViewMode(QPrintPreviewWidget::AllPagesView)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setCurrentPage
(
pageNumber
)
¶
pageNumber
–
int
Sets the current page in the preview. This will cause the view to skip to the beginning of
page
.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
setFacingPagesViewMode
(
)
¶
This is a convenience function and is the same as calling
setViewMode(QPrintPreviewWidget::FacingPagesView)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setLandscapeOrientation
(
)
¶
This is a convenience function and is the same as calling
setOrientation(QPrinter::Landscape)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setOrientation
(
orientation
)
¶
orientation
–
取向
Sets the current orientation to
orientation
. This value will be set on the
QPrinter
object associated with the preview.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
setPortraitOrientation
(
)
¶
This is a convenience function and is the same as calling
setOrientation(QPrinter::Portrait)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setSinglePageViewMode
(
)
¶
This is a convenience function and is the same as calling
setViewMode(QPrintPreviewWidget::SinglePageView)
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
setViewMode
(
viewMode
)
¶
viewMode
–
ViewMode
Sets the view mode to
mode
. The default view mode is
SinglePageView
.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
setZoomFactor
(
zoomFactor
)
¶
zoomFactor
–
qreal
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.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
setZoomMode
(
zoomMode
)
¶
zoomMode
–
ZoomMode
Sets the zoom mode to
zoomMode
. The default zoom mode is
FitInView
.
PySide2.QtPrintSupport.QPrintPreviewWidget.
updatePreview
(
)
¶
This function updates the preview, which causes the
paintRequested()
signal to be emitted.
PySide2.QtPrintSupport.QPrintPreviewWidget.
viewMode
(
)
¶
Returns the current view mode. The default view mode is
SinglePageView
.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
zoomFactor
(
)
¶
qreal
Returns the zoom factor of the view.
另请参阅
PySide2.QtPrintSupport.QPrintPreviewWidget.
zoomIn
(
[
zoom=1.1
]
)
¶
zoom
–
qreal
Zooms the current view in by
factor
. The default value for
factor
is 1.1, which means the view will be scaled up by 10%.
PySide2.QtPrintSupport.QPrintPreviewWidget.
zoomMode
(
)
¶
Returns the current zoom mode.
PySide2.QtPrintSupport.QPrintPreviewWidget.
zoomOut
(
[
zoom=1.1
]
)
¶
zoom
–
qreal
Zooms the current view out by
factor
. The default value for
factor
is 1.1, which means the view will be scaled down by 10%.