Class QAccelPlot::PlotExporter¶
ClassList > QAccelPlot > PlotExporter
Exports a plot as a raster image: to a file, to the clipboard, or as a QImage .More...
#include <PlotExporter.hpp>
Inherits the following classes: QObject
Inheritance diagram¶
flowchart TB
classQAccelPlot_1_1PlotExporter["QAccelPlot::PlotExporter"]
external_base_classQAccelPlot_1_1PlotExporter_1["QObject"]
external_base_classQAccelPlot_1_1PlotExporter_1 --> classQAccelPlot_1_1PlotExporter
Public Properties¶
| Type | Name |
|---|---|
| property bool | busy True from a request until its finished() signal. |
| property qreal | dpi Resolution stored in saved files, in dots per inch; 0 stores 96 times the effective scale. Default: 0. |
| property PlotView * | plot Plot to export; null once the plot is destroyed. |
| property int | quality Encoder quality from 0 to 100 passed to QImageWriter ; -1 uses the format's default. Default: -1. |
| property qreal | scale Image pixels per logical pixel; 0 uses the window's device pixel ratio. Default: 0. |
| property bool | transparentBackground Leaves out the plot's axesAreaColor andplotAreaColor backgrounds. Default: false. |
Public Signals¶
| Type | Name |
|---|---|
| signal void | busyChanged Emitted when the busy property changes. |
| signal void | dpiChanged Emitted when the dpi property changes. |
| signal void | finished (bool ok, const QString & path, const QString & error) Emitted when a request ends; path is the saved file, empty for other requests. |
| signal void | imageReady (const QImage & image) Emitted with the captured image before finished() for agrabImage() request. |
| signal void | plotChanged Emitted when the plot property changes. |
| signal void | qualityChanged Emitted when the quality property changes. |
| signal void | scaleChanged Emitted when the scale property changes. |
| signal void | transparentBackgroundChanged Emitted when the transparentBackground property changes. |
Public Functions¶
| Type | Name |
|---|---|
| PlotExporter (QObject * parent=nullptr) Constructs an exporter without a plot. |
|
| PlotExporter (const PlotExporter &) = delete |
|
| PlotExporter (PlotExporter &&) = delete |
|
| bool | busy () const Returns true while a request is in progress. |
| Q_INVOKABLE bool | copyToClipboard () Copies the plot image to the clipboard; returns false when the request fails immediately. |
| qreal | dpi () const Returns the resolution stored in saved files; 0 means 96 times the effective scale. |
| Q_INVOKABLE bool | grabImage () Captures the plot and emits imageReady() ; returns false when the request fails immediately. |
| PlotExporter & | operator= (const PlotExporter &) = delete |
| PlotExporter & | operator= (PlotExporter &&) = delete |
| PlotView * | plot () const Returns the plot to export. |
| int | quality () const Returns the encoder quality. |
| Q_INVOKABLE bool | save (const QString & path) Saves the plot to path in the format its suffix names. |
| qreal | scale () const Returns the image pixels per logical pixel; 0 means the window's device pixel ratio. |
| void | setDpi (qreal dpi) Sets the stored resolution; negative and nonfinite values are ignored with a warning. |
| void | setPlot (PlotView * plot) Sets the plot to export; a request in progress keeps its plot. |
| void | setQuality (int quality) Sets the encoder quality; values outside -1 to 100 are ignored with a warning. |
| void | setScale (qreal scale) Sets the image pixels per logical pixel; negative and nonfinite values are ignored with a warning. |
| void | setTransparentBackground (bool transparent) Sets whether the image leaves out the plot's backgrounds. |
| bool | transparentBackground () const Returns whether the image leaves out the plot's backgrounds. |
| ~PlotExporter () override Restores the plot's appearance if a capture is in progress. |
Public Static Functions¶
| Type | Name |
|---|---|
| Q_INVOKABLE QStringList | supportedFormats () Returns the lowercase file suffixes save() accepts on this system, such aspng andjpg . |
Detailed Description¶
The capture contains the plot item and everything drawn inside its bounds, as on screen: series, axes, legend, overlays, and any child items. Children outside the bounds are clipped. The plot must be visible in a window that is shown, not minimized, and renders through a hardware scene graph backend.
Every request is asynchronous and ends with exactly one finished() signal, except one made while busy: it returns false with a warning and leaves finished() to the request in progress. A request for a plot another exporter is capturing fails. The capture is taken on the next frame, and fails when the window is hidden, minimized, or destroyed first; encoding and writing a file run on a worker thread.
** **
PlotExporter {
id: exporter
plot: myPlot
scale: 2
onFinished: (ok, path, error) => console.log(ok ? "Saved " + path : error)
}
Button { text: "Save"; onClicked: exporter.save("plot.png") }
See also: PlotView
Public Properties Documentation¶
property busy¶
True from a request until its finished() signal.
property dpi¶
Resolution stored in saved files, in dots per inch; 0 stores 96 times the effective scale. Default: 0.
The default makes documents place the image at its on-screen size.
property plot¶
Plot to export; null once the plot is destroyed.
property quality¶
Encoder quality from 0 to 100 passed to QImageWriter ; -1 uses the format's default. Default: -1.
Lossy formats (JPEG, WebP) trade file size for artifacts. PNG stays lossless and only trades file size for encoding time. Other formats ignore it.
property scale¶
Image pixels per logical pixel; 0 uses the window's device pixel ratio. Default: 0.
At a device pixel ratio other than 1, Qt 6.3 and later cannot render every image size, so a side can be a pixel shorter or longer than the plot's size times the scale.
property transparentBackground¶
Leaves out the plot's axesAreaColor andplotAreaColor backgrounds. Default: false.
Grid, series, axes, and child items such as the legend are drawn as usual. Formats without an alpha channel, such as JPEG, composite the image over white. The plot shows no background for the frame it is captured in.
Public Signals Documentation¶
signal busyChanged¶
Emitted when the busy property changes.
signal dpiChanged¶
Emitted when the dpi property changes.
signal finished¶
Emitted when a request ends; path is the saved file, empty for other requests.
ok is false when the request failed, and error describes why.
signal imageReady¶
Emitted with the captured image beforefinished() for agrabImage() request.
signal plotChanged¶
Emitted when the plot property changes.
signal qualityChanged¶
Emitted when the quality property changes.
signal scaleChanged¶
Emitted when the scale property changes.
signal transparentBackgroundChanged¶
Emitted when the transparentBackground property changes.
Public Functions Documentation¶
function PlotExporter¶
Constructs an exporter without a plot.
function PlotExporter¶
function PlotExporter¶
function busy¶
Returns true while a request is in progress.
function copyToClipboard¶
Copies the plot image to the clipboard; returns false when the request fails immediately.
function dpi¶
Returns the resolution stored in saved files; 0 means 96 times the effective scale.
function grabImage¶
Captures the plot and emits imageReady() ; returns false when the request fails immediately.
function operator=¶
function operator=¶
function plot¶
Returns the plot to export.
function quality¶
Returns the encoder quality.
function save¶
Saves the plot to path in the format its suffix names.
path may be a local file path or a file: URL. An existing file is replaced only when the new one is written completely. Returns false when the request fails immediately, after emitting finished() unless the exporter is busy.
function scale¶
Returns the image pixels per logical pixel; 0 means the window's device pixel ratio.
function setDpi¶
Sets the stored resolution; negative and nonfinite values are ignored with a warning.
function setPlot¶
Sets the plot to export; a request in progress keeps its plot.
function setQuality¶
Sets the encoder quality; values outside -1 to 100 are ignored with a warning.
function setScale¶
Sets the image pixels per logical pixel; negative and nonfinite values are ignored with a warning.
function setTransparentBackground¶
Sets whether the image leaves out the plot's backgrounds.
function transparentBackground¶
Returns whether the image leaves out the plot's backgrounds.
function ~PlotExporter¶
Restores the plot's appearance if a capture is in progress.
Public Static Functions Documentation¶
function supportedFormats¶
Returns the lowercase file suffixes save() accepts on this system, such aspng andjpg .
The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/export/PlotExporter.hpp