QSvgGenerator Class Reference |
|
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.
This property holds the description of the generated SVG drawing.
This property was introduced in Qt 4.5.
Access functions:
See also title.
This property holds the target filename for the generated SVG drawing.
This property was introduced in Qt 4.5.
Access functions:
See also outputDevice.
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:
See also fileName.
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:
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:
See also viewBox and resolution.
This property holds the title of the generated SVG drawing.
This property was introduced in Qt 4.5.
Access functions:
See also description.
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:
See also viewBox(), size, and resolution.
Constructs a new generator.
Destroys the generator.
Returns the paint engine used to render graphics to be converted to SVG format information.
Reimplemented from QPaintDevice.
Returns viewBoxF().toRect().
This function was introduced in Qt 4.5.
See also setViewBox() and viewBoxF().
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.5 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com