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  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QSvgGenerator Class Reference

The QSvgGenerator class provides a paint device that is used to create SVG drawings. More...

 #include <QSvgGenerator>

Inherits: QPaintDevice.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.3.

Properties

Public Functions

QSvgGenerator ()
~QSvgGenerator ()
QString description () const
QString fileName () const
QIODevice * outputDevice () const
int resolution () const
void setDescription ( const QString & description )
void setFileName ( const QString & fileName )
void setOutputDevice ( QIODevice * outputDevice )
void setResolution ( int dpi )
void setSize ( const QSize & size )
void setTitle ( const QString & title )
void setViewBox ( const QRect & viewBox )
void setViewBox ( const QRectF & viewBox )
QSize size () const
QString title () const
QRect viewBox () const
QRectF viewBoxF () const

Reimplemented Protected Functions

virtual int metric ( QPaintDevice::PaintDeviceMetric metric ) const
virtual QPaintEngine * paintEngine () const

Detailed Description

The QSvgGenerator class provides a paint device that is used to create SVG drawings.

This paint device represents a Scalable Vector Graphics (SVG) drawing. Like QPrinter, it is designed as a write-only device that generates output in a specific format.

To write an SVG file, you first need to configure the output by setting the fileName or outputDevice properties. It is usually necessary to specify the size of the drawing by setting the size property, and in some cases where the drawing will be included in another, the viewBox property also needs to be set.

     QSvgGenerator generator;
     generator.setFileName(path);
     generator.setSize(QSize(200, 200));
     generator.setViewBox(QRect(0, 0, 200, 200));
     generator.setTitle(tr("SVG Generator Example Drawing"));
     generator.setDescription(tr("An SVG drawing created by the SVG Generator "
                                 "Example provided with Qt."));

Other meta-data can be specified by setting the title, description and resolution properties.

As with other QPaintDevice subclasses, a QPainter object is used to paint onto an instance of this class:

     QPainter painter;
     painter.begin(&generator);
     ...
     painter.end();

Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter::begin() and end() to explicitly begin and end painting on the device.

The SVG Generator Example shows how the same painting commands can be used for painting a widget and writing an SVG file.

See also QSvgRenderer, QSvgWidget, and About SVG.

Property Documentation

description : QString

This property holds the description of the generated SVG drawing.

This property was introduced in Qt 4.5.

Access functions:

QString description () const
void setDescription ( const QString & description )

See also title.

fileName : QString

This property holds the target filename for the generated SVG drawing.

This property was introduced in Qt 4.5.

Access functions:

QString fileName () const
void setFileName ( const QString & fileName )

See also outputDevice.

outputDevice : QIODevice *

This property holds the output device for the generated SVG drawing.

If both output device and file name are specified, the output device will have precedence.

This property was introduced in Qt 4.5.

Access functions:

QIODevice * outputDevice () const
void setOutputDevice ( QIODevice * outputDevice )

See also fileName.

resolution : int

This property holds the resolution of the generated output.

The resolution is specified in dots per inch, and is used to calculate the physical size of an SVG drawing.

This property was introduced in Qt 4.5.

Access functions:

int resolution () const
void setResolution ( int dpi )

See also size and viewBox.

size : QSize

This property holds the size of the generated SVG drawing.

By default this property is set to QSize(-1, -1), which indicates that the generator should not output the width and height attributes of the <svg> element.

Note: It is not possible to change this property while a QPainter is active on the generator.

This property was introduced in Qt 4.5.

Access functions:

QSize size () const
void setSize ( const QSize & size )

See also viewBox and resolution.

title : QString

This property holds the title of the generated SVG drawing.

This property was introduced in Qt 4.5.

Access functions:

QString title () const
void setTitle ( const QString & title )

See also description.

viewBox : QRectF

This property holds the viewBox of the generated SVG drawing.

By default this property is set to QRect(0, 0, -1, -1), which indicates that the generator should not output the viewBox attribute of the <svg> element.

Note: It is not possible to change this property while a QPainter is active on the generator.

This property was introduced in Qt 4.5.

Access functions:

QRectF viewBoxF () const
void setViewBox ( const QRect & viewBox )
void setViewBox ( const QRectF & viewBox )

See also viewBox(), size, and resolution.

Member Function Documentation

QSvgGenerator::QSvgGenerator ()

Constructs a new generator.

QSvgGenerator::~QSvgGenerator ()

Destroys the generator.

int QSvgGenerator::metric ( QPaintDevice::PaintDeviceMetric metric ) const [virtual protected]

Reimplemented from QPaintDevice::metric().

QPaintEngine * QSvgGenerator::paintEngine () const [virtual protected]

Reimplemented from QPaintDevice::paintEngine().

Returns the paint engine used to render graphics to be converted to SVG format information.

QRect QSvgGenerator::viewBox () const

Returns viewBoxF().toRect().

This function was introduced in Qt 4.5.

See also setViewBox() and viewBoxF().

Publicit�

Best Of

Actualit�s les plus lues

Semaine
Mois
Ann�e
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la sp�cification pour la conception d'applications parall�les C++ utilisant le GPU 22
  2. Les d�veloppeurs ignorent-ils trop les failles d�couvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : � 13 % des d�veloppeurs ont gagn� plus de 100 000 $ sur l'AppWord �, Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. � Quelque chose ne va vraiment pas avec les d�veloppeurs "modernes" �, un d�veloppeur � "l'ancienne" critique la multiplication des biblioth�ques 12
  5. BlackBerry 10 : premi�res images du prochain OS de RIM qui devrait int�grer des widgets et des tuiles inspir�es de Windows Phone 0
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil d�claratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveaut�s de C++11 Visual C++ doit-il rapidement int�grer ? Donnez-nous votre avis 10
Page suivante

Le Qt Developer Network au hasard

Logo

Compiler l'add-in Qt de Visual Studio

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