Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qprintpreviewwidget.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6#include "private/qwidget_p.h"
7#include <private/qprinter_p.h>
8
9#include <QtCore/qmath.h>
10#include <QtWidgets/qboxlayout.h>
11#include <QtWidgets/qgraphicsitem.h>
12#include <QtWidgets/qgraphicsview.h>
13#include <QtWidgets/qscrollbar.h>
14#include <QtWidgets/qstyleoption.h>
15
17
18namespace QtPrivate {
19class PageItem : public QGraphicsItem
20{
21public:
22 PageItem(int _pageNum, const QPicture* _pagePicture, QSize _paperSize, QRect _pageRect)
23 : pageNum(_pageNum), pagePicture(_pagePicture),
25 {
26 qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
27 brect = QRectF(QPointF(-border, -border),
28 QSizeF(paperSize)+QSizeF(2*border, 2*border));
29 }
30
31 QRectF boundingRect() const override
32 { return brect; }
33
34 inline int pageNumber() const
35 { return pageNum; }
36
37 void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override;
38
39private:
40 int pageNum;
41 const QPicture* pagePicture;
42 QSize paperSize;
43 QRect pageRect;
44 QRectF brect;
45};
46
47void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
48{
49 Q_UNUSED(widget);
50
51#if 0
52 // Draw item bounding rect, for debugging
53 painter->save();
54 painter->setPen(QPen(Qt::red, 0));
55 painter->setBrush(Qt::NoBrush);
56 painter->drawRect(QRectF(-border()+1.0, -border()+1.0, boundingRect().width()-2, boundingRect().height()-2));
57 painter->restore();
58#endif
59
60 QRectF paperRect(0,0, paperSize.width(), paperSize.height());
61
62 // Draw shadow
63 painter->setClipRect(option->exposedRect);
64 qreal shWidth = paperRect.width()/100;
65 QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
66 paperRect.bottomRight() + QPointF(shWidth, 0));
67 QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
68 rgrad.setColorAt(0.0, QColor(0,0,0,255));
69 rgrad.setColorAt(1.0, QColor(0,0,0,0));
70 painter->fillRect(rshadow, QBrush(rgrad));
71 QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
72 paperRect.bottomRight() + QPointF(0, shWidth));
73 QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
74 bgrad.setColorAt(0.0, QColor(0,0,0,255));
75 bgrad.setColorAt(1.0, QColor(0,0,0,0));
76 painter->fillRect(bshadow, QBrush(bgrad));
77 QRectF cshadow(paperRect.bottomRight(),
78 paperRect.bottomRight() + QPointF(shWidth, shWidth));
79 QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
80 cgrad.setColorAt(0.0, QColor(0,0,0,255));
81 cgrad.setColorAt(1.0, QColor(0,0,0,0));
82 painter->fillRect(cshadow, QBrush(cgrad));
83
84 painter->setClipRect(paperRect & option->exposedRect);
85 painter->fillRect(paperRect, Qt::white);
86 if (!pagePicture)
87 return;
88 painter->drawPicture(pageRect.topLeft(), *pagePicture);
89
90 // Effect: make anything drawn in the margins look washed out.
91 QPainterPath path;
92 path.addRect(paperRect);
93 path.addRect(pageRect);
94 painter->setPen(QPen(Qt::NoPen));
95 painter->setBrush(QColor(255, 255, 255, 180));
96 painter->drawPath(path);
97
98#if 0
99 // Draw frame around paper.
100 painter->setPen(QPen(Qt::black, 0));
101 painter->setBrush(Qt::NoBrush);
102 painter->drawRect(paperRect);
103#endif
104
105 // todo: drawtext "Page N" below paper
106}
107
109{
111public:
114 {
115#ifdef Q_OS_APPLE
117#endif
118 }
119signals:
120 void resized();
121
122protected:
123 void resizeEvent(QResizeEvent* e) override
124 {
125 {
126 const QSignalBlocker blocker(verticalScrollBar()); // Don't change page, QTBUG-14517
127 QGraphicsView::resizeEvent(e);
128 }
129 emit resized();
130 }
131
132 void showEvent(QShowEvent* e) override
133 {
134 QGraphicsView::showEvent(e);
135 emit resized();
136 }
137};
138
139} // namespace QtPrivate
140
143
183
184void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting)
185{
186 Q_Q(QPrintPreviewWidget);
187
188 if (curPage < 1 || curPage > pages.size())
189 return;
190
191 if (!doFitting && !fitting)
192 return;
193
194 if (doFitting && fitting) {
195 QRect viewRect = graphicsView->viewport()->rect();
196 if (zoomMode == QPrintPreviewWidget::FitInView) {
197 const QList<QGraphicsItem*> containedItems = graphicsView->items(viewRect, Qt::ContainsItemBoundingRect);
198 for (QGraphicsItem* item : containedItems) {
199 PageItem* pg = static_cast<PageItem*>(item);
200 if (pg->pageNumber() == curPage)
201 return;
202 }
203 }
204
205 int newPage = calcCurrentPage();
206 if (newPage != curPage)
207 curPage = newPage;
208 }
209
210 QRectF target = pages.at(curPage-1)->sceneBoundingRect();
211 if (viewMode == QPrintPreviewWidget::FacingPagesView) {
212 // fit two pages
213 if (curPage % 2)
214 target.setLeft(target.left() - target.width());
215 else
216 target.setRight(target.right() + target.width());
217 } else if (viewMode == QPrintPreviewWidget::AllPagesView) {
218 target = scene->itemsBoundingRect();
219 }
220
221 if (zoomMode == QPrintPreviewWidget::FitToWidth) {
222 QTransform t;
223 qreal scale = graphicsView->viewport()->width() / target.width();
224 t.scale(scale, scale);
225 graphicsView->setTransform(t);
226 if (doFitting && fitting) {
227 QRectF viewSceneRect = graphicsView->viewportTransform().mapRect(graphicsView->viewport()->rect());
228 viewSceneRect.moveTop(target.top());
229 graphicsView->ensureVisible(viewSceneRect); // Nah...
230 }
231 } else {
232 graphicsView->fitInView(target, Qt::KeepAspectRatio);
233 if (zoomMode == QPrintPreviewWidget::FitInView) {
234 const int step = qRound(graphicsView->transform().mapRect(target).height());
235 graphicsView->verticalScrollBar()->setSingleStep(step);
236 graphicsView->verticalScrollBar()->setPageStep(step);
237 }
238 }
239
240 zoomFactor = graphicsView->transform().m11() * (float(printer->logicalDpiY()) / q->logicalDpiY());
241 emit q->previewChanged();
242}
243
245{
246 Q_Q(QPrintPreviewWidget);
247
248 if (viewMode == QPrintPreviewWidget::AllPagesView)
249 return;
250
251 int newPage = calcCurrentPage();
252 if (newPage != curPage) {
253 curPage = newPage;
254 emit q->previewChanged();
255 }
256}
257
259{
260 int maxArea = 0;
261 int newPage = curPage;
262 QRect viewRect = graphicsView->viewport()->rect();
263 const QList<QGraphicsItem*> items = graphicsView->items(viewRect);
264 for (auto *item : items) {
265 PageItem* pg = static_cast<PageItem*>(item);
266 QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
267 int area = overlap.width() * overlap.height();
268 if (area > maxArea) {
269 maxArea = area;
270 newPage = pg->pageNumber();
271 } else if (area == maxArea && pg->pageNumber() < newPage) {
272 newPage = pg->pageNumber();
273 }
274 }
275 return newPage;
276}
277
279{
280 Q_Q(QPrintPreviewWidget);
281
283 graphicsView->setInteractive(false);
284 graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
285 graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
286 QObject::connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)),
287 q, SLOT(_q_updateCurrentPage()));
288 QObject::connect(graphicsView, SIGNAL(resized()), q, SLOT(_q_fit()));
289
290 scene = new QGraphicsScene(graphicsView);
291 scene->setBackgroundBrush(Qt::gray);
292 graphicsView->setScene(scene);
293
294 QVBoxLayout *layout = new QVBoxLayout(q);
295 layout->setContentsMargins(0, 0, 0, 0);
296 layout->addWidget(graphicsView);
297}
298
300{
301 // remove old pages
302 for (auto *page : std::as_const(pages))
303 scene->removeItem(page);
304 qDeleteAll(pages);
305 pages.clear();
306
307 QSize paperSize = printer->pageLayout().fullRectPixels(printer->resolution()).size();
308 QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
309
310 int page = 1;
311 for (auto *picture : std::as_const(pictures)) {
312 PageItem* item = new PageItem(page++, picture, paperSize, pageRect);
313 scene->addItem(item);
314 pages.append(item);
315 }
316}
317
319{
320 int numPages = pages.size();
321 if (numPages < 1)
322 return;
323
324 int numPagePlaces = numPages;
325 int cols = 1; // singleMode and default
326 if (viewMode == QPrintPreviewWidget::AllPagesView) {
327 if (printer->pageLayout().orientation() == QPageLayout::Portrait)
328 cols = qCeil(qSqrt((float) numPages));
329 else
330 cols = qFloor(qSqrt((float) numPages));
331 cols += cols % 2; // Nicer with an even number of cols
332 }
333 else if (viewMode == QPrintPreviewWidget::FacingPagesView) {
334 cols = 2;
335 numPagePlaces += 1;
336 }
337 int rows = qCeil(qreal(numPagePlaces) / cols);
338
339 qreal itemWidth = pages.at(0)->boundingRect().width();
340 qreal itemHeight = pages.at(0)->boundingRect().height();
341 int pageNum = 1;
342 for (int i = 0; i < rows && pageNum <= numPages; i++) {
343 for (int j = 0; j < cols && pageNum <= numPages; j++) {
344 if (!i && !j && viewMode == QPrintPreviewWidget::FacingPagesView) {
345 // Front page doesn't have a facing page
346 continue;
347 } else {
348 pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
349 pageNum++;
350 }
351 }
352 }
353 scene->setSceneRect(scene->itemsBoundingRect());
354}
355
357{
358 //### If QPrinter::setPreviewMode() becomes public, handle the
359 //### case that we have been constructed with a printer that
360 //### _already_ has been preview-painted to, so we should
361 //### initially just show the pages it already contains, and not
362 //### emit paintRequested() until the user changes some parameter
363
364 Q_Q(QPrintPreviewWidget);
365 // Avoid previewing a preview
366 if (printer->d_func()->previewMode())
367 return;
368 printer->d_func()->setPreviewMode(true);
369 emit q->paintRequested(printer);
370 printer->d_func()->setPreviewMode(false);
371 pictures = printer->d_func()->previewPages();
372 populateScene(); // i.e. setPreviewPrintedPictures() e.l.
374 curPage = pages.size() > 0 ? qBound(1, curPage, pages.size()) : 1;
375 if (fitting)
376 _q_fit();
377 emit q->previewChanged();
378}
379
381{
382 if (pageNumber < 1 || pageNumber > pages.size())
383 return;
384
385 int lastPage = curPage;
386 curPage = pageNumber;
387
388 if (lastPage != curPage && lastPage > 0 && lastPage <= pages.size()) {
389 if (zoomMode != QPrintPreviewWidget::FitInView) {
390 QScrollBar *hsc = graphicsView->horizontalScrollBar();
391 QScrollBar *vsc = graphicsView->verticalScrollBar();
392 QPointF pt = graphicsView->transform().map(pages.at(curPage-1)->pos());
393 vsc->setValue(int(pt.y()) - 10);
394 hsc->setValue(int(pt.x()) - 10);
395 } else {
396 graphicsView->centerOn(pages.at(curPage-1));
397 }
398 }
399}
400
402{
403 zoomFactor *= zoom;
404 graphicsView->scale(zoom, zoom);
405}
406
408{
409 Q_Q(QPrintPreviewWidget);
410 zoomFactor = _zoomFactor;
411 graphicsView->resetTransform();
412 int dpi_y = q->logicalDpiY();
413 int printer_dpi_y = printer->logicalDpiY();
414 graphicsView->scale(zoomFactor*(dpi_y/float(printer_dpi_y)),
415 zoomFactor*(dpi_y/float(printer_dpi_y)));
416}
417
418///////////////////////////////////////
419
420/*!
421 \class QPrintPreviewWidget
422 \since 4.4
423
424 \brief The QPrintPreviewWidget class provides a widget for
425 previewing page layouts for printer output.
426
427 \ingroup printing
428 \inmodule QtPrintSupport
429
430 QPrintPreviewDialog uses a QPrintPreviewWidget internally, and the
431 purpose of QPrintPreviewWidget is to make it possible to embed the
432 preview into other widgets. It also makes it possible to build a different
433 user interface around it than the default one provided with QPrintPreviewDialog.
434
435 Using QPrintPreviewWidget is straightforward:
436
437 \list 1
438 \li Create the QPrintPreviewWidget
439
440 Construct the QPrintPreviewWidget either by passing in an
441 existing QPrinter object, or have QPrintPreviewWidget create a
442 default constructed QPrinter object for you.
443
444 \li Connect the paintRequested() signal to a slot.
445
446 When the widget needs to generate a set of preview pages, a
447 paintRequested() signal will be emitted from the widget. Connect a
448 slot to this signal, and draw onto the QPrinter passed in as a
449 signal parameter. Call QPrinter::newPage(), to start a new
450 page in the preview.
451
452 \endlist
453
454 \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewDialog
455*/
456
457
458/*!
459 \enum QPrintPreviewWidget::ViewMode
460
461 This enum is used to describe the view mode of the preview widget.
462
463 \value SinglePageView A mode where single pages in the preview
464 is viewed.
465
466 \value FacingPagesView A mode where the facing pages in the preview
467 is viewed.
468
469 \value AllPagesView A view mode where all the pages in the preview
470 is viewed.
471*/
472
473/*!
474 \enum QPrintPreviewWidget::ZoomMode
475
476 This enum is used to describe zoom mode of the preview widget.
477
478 \value CustomZoom The zoom is set to a custom zoom value.
479
480 \value FitToWidth This mode fits the current page to the width of the view.
481
482 \value FitInView This mode fits the current page inside the view.
483
484*/
485
486/*!
487 Constructs a QPrintPreviewWidget based on \a printer and with \a
488 parent as the parent widget. The widget flags \a flags are passed on
489 to the QWidget constructor.
490
491 \sa QWidget::setWindowFlags()
492*/
493QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags)
494 : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
495{
496 Q_D(QPrintPreviewWidget);
497 d->printer = printer;
498 d->ownPrinter = false;
499 d->init();
500}
501
502/*!
503 \overload
504
505 This will cause QPrintPreviewWidget to create an internal, default
506 constructed QPrinter object, which will be used to generate the
507 preview.
508*/
509QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags)
510 : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
511{
512 Q_D(QPrintPreviewWidget);
513 d->printer = new QPrinter;
514 d->ownPrinter = true;
515 d->init();
516}
517
518
519/*!
520 Destroys the QPrintPreviewWidget.
521*/
522QPrintPreviewWidget::~QPrintPreviewWidget()
523{
524 Q_D(QPrintPreviewWidget);
525 if (d->ownPrinter)
526 delete d->printer;
527}
528
529/*!
530 Returns the current view mode. The default view mode is SinglePageView.
531*/
532QPrintPreviewWidget::ViewMode QPrintPreviewWidget::viewMode() const
533{
534 Q_D(const QPrintPreviewWidget);
535 return d->viewMode;
536}
537
538/*!
539 Sets the view mode to \a mode. The default view mode is
540 SinglePageView.
541*/
542void QPrintPreviewWidget::setViewMode(ViewMode mode)
543{
544 Q_D(QPrintPreviewWidget);
545 d->viewMode = mode;
546 d->layoutPages();
547 if (d->viewMode == AllPagesView) {
548 d->graphicsView->fitInView(d->scene->itemsBoundingRect(), Qt::KeepAspectRatio);
549 d->fitting = false;
550 d->zoomMode = QPrintPreviewWidget::CustomZoom;
551 d->zoomFactor = d->graphicsView->transform().m11() * (float(d->printer->logicalDpiY()) / logicalDpiY());
552 emit previewChanged();
553 } else {
554 d->fitting = true;
555 d->_q_fit();
556 }
557}
558
559/*!
560 Returns the current orientation of the preview. This value is
561 obtained from the QPrinter object associated with the preview.
562*/
563QPageLayout::Orientation QPrintPreviewWidget::orientation() const
564{
565 Q_D(const QPrintPreviewWidget);
566 return d->printer->pageLayout().orientation();
567}
568
569/*!
570 Sets the current orientation to \a orientation. This value will be
571 set on the QPrinter object associated with the preview.
572*/
573void QPrintPreviewWidget::setOrientation(QPageLayout::Orientation orientation)
574{
575 Q_D(QPrintPreviewWidget);
576 d->printer->setPageOrientation(orientation);
577 d->generatePreview();
578}
579
580/*!
581 Prints the preview to the printer associated with the preview.
582*/
583void QPrintPreviewWidget::print()
584{
585 Q_D(QPrintPreviewWidget);
586 // ### make use of the generated pages
587 emit paintRequested(d->printer);
588}
589
590/*!
591 Zooms the current view in by \a factor. The default value for \a
592 factor is 1.1, which means the view will be scaled up by 10%.
593*/
594void QPrintPreviewWidget::zoomIn(qreal factor)
595{
596 Q_D(QPrintPreviewWidget);
597 d->fitting = false;
598 d->zoomMode = QPrintPreviewWidget::CustomZoom;
599 d->zoom(factor);
600}
601
602/*!
603 Zooms the current view out by \a factor. The default value for \a
604 factor is 1.1, which means the view will be scaled down by 10%.
605*/
606void QPrintPreviewWidget::zoomOut(qreal factor)
607{
608 Q_D(QPrintPreviewWidget);
609 d->fitting = false;
610 d->zoomMode = QPrintPreviewWidget::CustomZoom;
611 d->zoom(1/factor);
612}
613
614/*!
615 Returns the zoom factor of the view.
616*/
617qreal QPrintPreviewWidget::zoomFactor() const
618{
619 Q_D(const QPrintPreviewWidget);
620 return d->zoomFactor;
621}
622
623/*!
624 Sets the zoom factor of the view to \a factor. For example, a
625 value of 1.0 indicates an unscaled view, which is approximately
626 the size the view will have on paper. A value of 0.5 will halve
627 the size of the view, while a value of 2.0 will double the size of
628 the view.
629*/
630void QPrintPreviewWidget::setZoomFactor(qreal factor)
631{
632 Q_D(QPrintPreviewWidget);
633 d->fitting = false;
634 d->zoomMode = QPrintPreviewWidget::CustomZoom;
635 d->setZoomFactor(factor);
636}
637
638/*!
639 \since 4.6
640 Returns the number of pages in the preview.
641*/
642int QPrintPreviewWidget::pageCount() const
643{
644 Q_D(const QPrintPreviewWidget);
645 return d->pages.size();
646}
647
648/*!
649 Returns the currently viewed page in the preview.
650*/
651int QPrintPreviewWidget::currentPage() const
652{
653 Q_D(const QPrintPreviewWidget);
654 return d->curPage;
655}
656
657/*!
658 Sets the current page in the preview. This will cause the view to
659 skip to the beginning of \a page.
660*/
661void QPrintPreviewWidget::setCurrentPage(int page)
662{
663 Q_D(QPrintPreviewWidget);
664 d->setCurrentPage(page);
665}
666
667/*!
668 This is a convenience function and is the same as calling \c
669 {setZoomMode(QPrintPreviewWidget::FitToWidth)}.
670*/
671void QPrintPreviewWidget::fitToWidth()
672{
673 setZoomMode(FitToWidth);
674}
675
676/*!
677 This is a convenience function and is the same as calling \c
678 {setZoomMode(QPrintPreviewWidget::FitInView)}.
679*/
680void QPrintPreviewWidget::fitInView()
681{
682 setZoomMode(FitInView);
683}
684
685/*!
686 Sets the zoom mode to \a zoomMode. The default zoom mode is FitInView.
687
688 \sa zoomMode(), viewMode(), setViewMode()
689*/
690void QPrintPreviewWidget::setZoomMode(QPrintPreviewWidget::ZoomMode zoomMode)
691{
692 Q_D(QPrintPreviewWidget);
693 d->zoomMode = zoomMode;
694 if (d->zoomMode == FitInView || d->zoomMode == FitToWidth) {
695 d->fitting = true;
696 d->_q_fit(true);
697 } else {
698 d->fitting = false;
699 }
700}
701
702/*!
703 Returns the current zoom mode.
704
705 \sa setZoomMode(), viewMode(), setViewMode()
706*/
707QPrintPreviewWidget::ZoomMode QPrintPreviewWidget::zoomMode() const
708{
709 Q_D(const QPrintPreviewWidget);
710 return d->zoomMode;
711}
712
713/*!
714 This is a convenience function and is the same as calling \c
715 {setOrientation(QPageLayout::Landscape)}.
716*/
717void QPrintPreviewWidget::setLandscapeOrientation()
718{
719 setOrientation(QPageLayout::Landscape);
720}
721
722/*!
723 This is a convenience function and is the same as calling \c
724 {setOrientation(QPageLayout::Portrait)}.
725*/
726void QPrintPreviewWidget::setPortraitOrientation()
727{
728 setOrientation(QPageLayout::Portrait);
729}
730
731/*!
732 This is a convenience function and is the same as calling \c
733 {setViewMode(QPrintPreviewWidget::SinglePageView)}.
734*/
735void QPrintPreviewWidget::setSinglePageViewMode()
736{
737 setViewMode(SinglePageView);
738}
739
740/*!
741 This is a convenience function and is the same as calling \c
742 {setViewMode(QPrintPreviewWidget::FacingPagesView)}.
743*/
744void QPrintPreviewWidget::setFacingPagesViewMode()
745{
746 setViewMode(FacingPagesView);
747}
748
749/*!
750 This is a convenience function and is the same as calling \c
751 {setViewMode(QPrintPreviewWidget::AllPagesView)}.
752*/
753void QPrintPreviewWidget::setAllPagesViewMode()
754{
755 setViewMode(AllPagesView);
756}
757
758
759/*!
760 This function updates the preview, which causes the
761 paintRequested() signal to be emitted.
762*/
763void QPrintPreviewWidget::updatePreview()
764{
765 Q_D(QPrintPreviewWidget);
766 d->initialized = true;
767 d->generatePreview();
768 d->graphicsView->updateGeometry();
769}
770
771/*! \reimp
772*/
773void QPrintPreviewWidget::setVisible(bool visible)
774{
775 Q_D(QPrintPreviewWidget);
776 if (visible && !d->initialized)
777 updatePreview();
778 QWidget::setVisible(visible);
779}
780
781/*!
782 \fn void QPrintPreviewWidget::paintRequested(QPrinter *printer)
783
784 This signal is emitted when the preview widget needs to generate a
785 set of preview pages. \a printer is the printer associated with
786 this preview widget.
787*/
788
789/*!
790 \fn void QPrintPreviewWidget::previewChanged()
791
792 This signal is emitted whenever the preview widget has changed
793 some internal state, such as the orientation.
794*/
795
796
797QT_END_NAMESPACE
798
799#include "moc_qprintpreviewwidget.cpp"
800#include "qprintpreviewwidget.moc"
QList< QGraphicsItem * > pages
QList< const QPicture * > pictures
void setZoomFactor(qreal zoomFactor)
void setCurrentPage(int pageNumber)
void resizeEvent(QResizeEvent *e) override
void showEvent(QShowEvent *e) override
QRectF boundingRect() const override
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override
This function, which is usually called by QGraphicsView, paints the contents of an item in local coor...
PageItem(int _pageNum, const QPicture *_pagePicture, QSize _paperSize, QRect _pageRect)
QtPrivate::GraphicsView GraphicsView
QtPrivate::PageItem PageItem