Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QPrintPreviewWidget Class Reference
[QtGui module]

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

 #include <QPrintPreviewWidget>

Inherits QWidget.

This class was introduced in Qt 4.4.

Public Types

  • enum ViewMode { SinglePageView, FacingPagesView, AllPagesView }
  • enum ZoomMode { CustomZoom, FitToWidth, FitInView }

Public Functions

  • 206 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Public Slots

  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Additional Inherited Members

  • 57 properties inherited from QWidget
  • 1 property inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 38 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

Detailed Description

The QPrintPreviewWidget class provides a widget for previewing page layouts for printer output.

QPrintPreviewDialog uses a QPrintPreviewWidget internally, and the purpose of QPrintPreviewWidget 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 with QPrintPreviewDialog.

Using QPrintPreviewWidget is straightforward:

  1. Create the QPrintPreviewWidget

    Construct the QPrintPreviewWidget either by passing in an exisiting QPrinter object, or have QPrintPreviewWidget create a default constructed QPrinter object for you.

  2. 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 QPrinter passed in as a signal parameter. Call QPrinter::newPage(), to start a new page in the preview.

See also QPrinter, QPrintDialog, QPageSetupDialog, and QPrintPreviewDialog.


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 a QPrintPreviewWidget based on printer and with parent as the parent widget. The widget flags flags are passed on to the QWidget constructor.

See also QWidget::setWindowFlags().

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

This will cause QPrintPreviewWidget to create an internal, default constructed QPrinter object, which will be used to generate the preview.

QPrintPreviewWidget::~QPrintPreviewWidget ()

Destroys the QPrintPreviewWidget.

int QPrintPreviewWidget::currentPage () const

Returns the currently viewed page in the preview.

See also setCurrentPage().

void QPrintPreviewWidget::fitInView ()   [slot]

This is a convenience function and is the same as calling setZoomMode(QPrintPreviewWidget::FitInView).

void QPrintPreviewWidget::fitToWidth ()   [slot]

This is a convenience function and is the same as calling setZoomMode(QPrintPreviewWidget::FitToWidth).

int QPrintPreviewWidget::numPages () const

Returns the number of pages in the preview.

QPrinter::Orientation QPrintPreviewWidget::orientation () const

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

See also setOrientation().

void QPrintPreviewWidget::paintRequested ( QPrinter * printer )   [signal]

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.

void QPrintPreviewWidget::previewChanged ()   [signal]

This signal is emitted whenever the preview widget has changed some internal state, such as the orientation.

void QPrintPreviewWidget::print ()   [slot]

Prints the preview to the printer associated with the preview.

void QPrintPreviewWidget::setAllPagesViewMode ()   [slot]

This is a convenience function and is the same as calling setViewMode(QPrintPreviewWidget::AllPagesView).

void QPrintPreviewWidget::setCurrentPage ( int page )   [slot]

Sets the current page in the preview. This will cause the view to skip to the beginning of page.

See also currentPage().

void QPrintPreviewWidget::setFacingPagesViewMode ()   [slot]

This is a convenience function and is the same as calling setViewMode(QPrintPreviewWidget::FacingPagesView).

void QPrintPreviewWidget::setLandscapeOrientation ()   [slot]

This is a convenience function and is the same as calling setOrientation(QPrinter::Landscape).

void QPrintPreviewWidget::setOrientation ( QPrinter::Orientation orientation )   [slot]

Sets the current orientation to orientation. This value will be set on the QPrinter object associated with the preview.

See also orientation().

void QPrintPreviewWidget::setPortraitOrientation ()   [slot]

This is a convenience function and is the same as calling setOrientation(QPrinter::Landscape).

void QPrintPreviewWidget::setSinglePageViewMode ()   [slot]

This is a convenience function and is the same as calling setViewMode(QPrintPreviewWidget::SinglePageView).

void QPrintPreviewWidget::setViewMode ( ViewMode mode )   [slot]

Sets the view mode to mode. The default view mode is SinglePageView.

See also viewMode().

void QPrintPreviewWidget::setZoomFactor ( qreal factor )   [slot]

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

void QPrintPreviewWidget::setZoomMode ( ZoomMode zoomMode )   [slot]

Sets the zoom mode to zoomMode. The default zoom mode is FitInView.

See also zoomMode(), viewMode(), and setViewMode().

void QPrintPreviewWidget::updatePreview ()   [slot]

This function updates the preview, which causes the paintRequested() signal to be emitted.

ViewMode QPrintPreviewWidget::viewMode () const

Returns the current view mode. The default view mode is SinglePageView.

See also setViewMode().

qreal QPrintPreviewWidget::zoomFactor () const

Returns the zoom factor of the view.

See also setZoomFactor().

void QPrintPreviewWidget::zoomIn ( qreal factor = 1.1 )   [slot]

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

ZoomMode QPrintPreviewWidget::zoomMode () const

Returns the current zoom mode.

See also setZoomMode(), viewMode(), and setViewMode().

void QPrintPreviewWidget::zoomOut ( qreal factor = 1.1 )   [slot]

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

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 48
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 13
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Génération de bindings PySide avec Shiboken

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web