QSvgGenerator Class
QSvgGeneratorクラスはSVG図面を作成するために使われるペイントデバイスを提供する。詳細...
ヘッダー | #include <QSvgGenerator> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Svg) target_link_libraries(mytarget PRIVATE Qt6::Svg) |
qmake: | QT += svg |
継承: | QPaintDevice |
- 継承されたメンバを含むすべてのメンバのリスト
- QSvgGenerator はPainting Classes の一部です。
注意:このクラスの全ての関数はリエントラントです。
パブリックタイプ
(since 6.5) enum class | SvgVersion { SvgTiny12, Svg11 } |
プロパティ
|
パブリック関数
QSvgGenerator() | |
(since 6.5) | QSvgGenerator(QSvgGenerator::SvgVersion version) |
virtual | ~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 |
(since 6.5) QSvgGenerator::SvgVersion | svgVersion() const |
QString | title() const |
QRect | viewBox() const |
QRectF | viewBoxF() const |
再実装された保護された関数
virtual int | metric(QPaintDevice::PaintDeviceMetric metric) const override |
virtual QPaintEngine * | paintEngine() const override |
詳細な説明
このペイントデバイスは Scalable Vector Graphics (SVG) 描画を表す。QPrinter のように、特定のフォーマットで出力を生成する書き込み専用デバイスとして設計されている。
SVG ファイルを書き込むには、まずfileName またはoutputDevice プロパティを設定して出力を設定する必要がある。通常、size プロパティを設定することで描画のサイズを指定する必要があり、描画が別のものに含まれるようなケースでは、viewBox プロパティも設定する必要があります。
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."));
その他のメタデータは、title 、description 、resolution プロパティを設定することで指定できます。
他のQPaintDevice サブクラスと同様に、QPainter オブジェクトを使用して、このクラスのインスタンスに描画します:
QPainter painter; painter.begin(&generator); ... painter.end();
ペイントは、他のペイント・デバイスと同じ方法で実行されます。ただし、QPainter::begin() とend() を使用して、デバイス上でのペイントを明示的に開始および終了する必要があります。
QSvgRenderer 、QSvgWidget 、および Qt SVG C++ Classes.
メンバ・タイプ・ドキュメント
[since 6.5]
enum class QSvgGenerator::SvgVersion
この列挙はジェネレータの SVG 出力のバージョンを記述する。
定数 | 値 | 説明 |
---|---|---|
QSvgGenerator::SvgVersion::SvgTiny12 | 0 | 生成された文書は SVG Tiny 1.2 仕様に従う。 |
QSvgGenerator::SvgVersion::Svg11 | 1 | 生成されたドキュメントは SVG 1.1 仕様に従う。 |
この列挙型は Qt 6.5 で導入されました。
プロパティ文書
description : QString
このプロパティは、生成された SVG 描画の記述を保持する。
アクセス関数を保持する:
QString | description() const |
void | setDescription(const QString &description) |
titleも参照 。
fileName : QString
このプロパティは、生成された SVG 描画のターゲットファイル名を保持する。
関数にアクセスする:
QString | fileName() const |
void | setFileName(const QString &fileName) |
outputDeviceも参照 。
outputDevice : QIODevice*
このプロパティは、生成される SVG 描画の出力デバイスを保持する。
出力デバイスとファイル名の両方が指定された場合、出力デバイスが優先される。
アクセス関数:
QIODevice * | outputDevice() const |
void | setOutputDevice(QIODevice *outputDevice) |
fileNameも参照 。
resolution : int
このプロパティは生成される出力の解像度を保持する。
解像度はドット毎インチで指定され、SVG 描画の物理的サイズを計算するのに用いられる。
アクセス関数:
int | resolution() const |
void | setResolution(int dpi) |
size : QSize
このプロパティは生成される SVG の描画サイズを保持する。
デフォルトでこのプロパティはQSize(-1, -1)
に設定され、ジェネレータが<svg>
要素の width と height 属性を出力しないことを示す。
注: QPainter がジェネレータ上でアクティブな間は、このプロパティを変更することはできない。
アクセス関数:
QSize | size() const |
void | setSize(const QSize &size) |
viewBox およびresolutionも参照して ください。
title : QString
このプロパティは生成された SVG 描画のタイトルを保持する。
アクセス関数:
QString | title() const |
void | setTitle(const QString &title) |
descriptionも参照 。
viewBox : QRectF
このプロパティは生成された SVG 図面の viewBox を保持する。
デフォルトでこのプロパティはQRect(0, 0, -1, -1)
に設定され、ジェネレータが<svg>
要素の viewBox 属性を出力しないことを示す。
注: QPainter がジェネレータ上でアクティブである間は、このプロパティを変更することはできない。
アクセス関数:
QRectF | viewBoxF() const |
void | setViewBox(const QRect &viewBox) |
void | setViewBox(const QRectF &viewBox) |
viewBox()、size 、およびresolutionも参照 。
メンバ関数ドキュメント
QSvgGenerator::QSvgGenerator()
SVG Tiny 1.2 プロファイルを使って新しいジェネレータを構築する。
[explicit, since 6.5]
QSvgGenerator::QSvgGenerator(QSvgGenerator::SvgVersion version)
SVG バージョンversion を使用する新しいジェネレーターを構築します。
この関数は Qt 6.5 で導入されました。
[virtual noexcept]
QSvgGenerator::~QSvgGenerator()
発電機を破壊する。
[override virtual protected]
int QSvgGenerator::metric(QPaintDevice::PaintDeviceMetric metric) const
再実装:QPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const.
[override virtual protected]
QPaintEngine *QSvgGenerator::paintEngine() const
再実装:QPaintDevice::paintEngine() const.
SVG 形式の情報に変換されるグラフィックのレンダリングに使用されるペイントエンジンを返します。
[since 6.5]
QSvgGenerator::SvgVersion QSvgGenerator::svgVersion() const
このジェネレータが生成している SVG ドキュメントのバージョンを返す。
この関数は Qt 6.5 で導入された。
QRect QSvgGenerator::viewBox() const
viewBoxF().toRect() を返します。
setViewBox() およびviewBoxF()も参照してください 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.