Helpers Class

Helper functions for building graphs. More...

Header: #include <QuickGraphLib>
Inherits: QObject

Static Public Members

QPicture exportToPicture(QQuickItem *item)
bool exportToPng(QQuickItem *item, QUrl path, int dpi = 96 * 2)
bool exportToSvg(QQuickItem *item, QUrl path)
QList<qreal> linspace(qreal min, qreal max, int num)
QPolygonF mapPoints(QVariant points, QMatrix4x4 dataTransform)
QList<int> range(int min, int max, int step = 1)
QList<qreal> tickLocator(qreal min, qreal max, int maxNum)

Detailed Description

See also QuickGraphLib::Helpers.

Member Function Documentation

[static invokable] QPicture Helpers::exportToPicture(QQuickItem *item)

Exports the graph in item to a QPicture.

Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.

Note: Using this method, followed by saving to an image should give the same result as the other functions (ignoring some differences in the output that result in equivalent display). One exception is that exporting an ImageView as SVG will result in images rendering using the "optimiseSpeed" setting when they are not smooth. For reliable rendering across multiple programs, it is better to replace this with "pixelated". Helpers::exportToSvg does this correction automatically.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Helpers::exportToPng, Helpers::exportToSvg, and Exporting graphs.

[static invokable] bool Helpers::exportToPng(QQuickItem *item, QUrl path, int dpi = 96 * 2)

Exports the graph in item to an PNG file at path with the resolution dpi. Returns a boolean indicating success.

Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Helpers::exportToSvg, Helpers::exportToPicture, and Exporting graphs.

[static invokable] bool Helpers::exportToSvg(QQuickItem *item, QUrl path)

Exports the graph in item to an SVG file at path. Returns a boolean indicating success.

Note: Only some QML elements are supported by this export method (e.g. Rectangle, PathPolyline). Other elements will be rendered incorrectly or not at all. See QPainter-based export for more information.

Note: Clip paths for SVGs are only supported in Qt 6.7+. If your graph needs clipping, ensure you are using a Qt version that supports it.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Helpers::exportToPng, Helpers::exportToPicture, and Exporting graphs.

[static invokable] QList<qreal> Helpers::linspace(qreal min, qreal max, int num)

Returns a list of num values equally spaced from min and max (inclusive).

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static invokable] QPolygonF Helpers::mapPoints(QVariant points, QMatrix4x4 dataTransform)

Maps each point in points though the transform defined by dataTransform.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static invokable] QList<int> Helpers::range(int min, int max, int step = 1)

Returns a list of values from min to max (exclusive) with a gap of step between each one.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static invokable] QList<qreal> Helpers::tickLocator(qreal min, qreal max, int maxNum)

Returns a list of at most maxNum nice tick locations values equally spaced between min and max.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.