Skip to content

Class QfDrawingCanvas

ClassList > QfDrawingCanvas

Inherits the following classes: QQuickPaintedItem

Public Properties

Type Name
property QfDrawingStroke currentStroke
property QColor frameColor
property bool isDirty
property bool isEmpty
property QPointF offset
property double zoomFactor

Public Signals

Type Name
signal void currentStrokeChanged
signal void frameColorChanged
signal void isDirtyChanged
signal void isEmptyChanged
signal void offsetChanged
signal void zoomFactorChanged

Public Functions

Type Name
QfDrawingCanvas (QQuickItem * parent=nullptr)
Q_INVOKABLE void clear ()
Q_INVOKABLE void createBlankCanvas (int width, int height, QColor backgroundColor=QColor(255, 255, 255))
Q_INVOKABLE void createCanvasFromImage (const QString & path)
QfDrawingStroke currentStroke () const
Q_INVOKABLE void fitCanvas ()
QColor frameColor () const
bool isDirty () const
bool isEmpty () const
QPointF offset () const
void paint (QPainter * painter) override
Q_INVOKABLE void pan (const QPointF & oldPosition, const QPointF & newPosition)
Q_INVOKABLE QString save () const
void setFrameColor (const QColor & color)
void setIsDirty (bool dirty)
void setIsEmpty (bool empty)
void setOffset (const QPointF & offset)
void setZoomFactor (double factor)
Q_INVOKABLE void strokeBegin (const QPointF & point, const QColor color=QColor(0, 0, 0))
Q_INVOKABLE void strokeEnd (const QPointF & point)
Q_INVOKABLE void strokeMove (const QPointF & point)
Q_INVOKABLE void undo ()
Q_INVOKABLE void zoom (double scale)
double zoomFactor () const
~QfDrawingCanvas () = default

Public Properties Documentation

property currentStroke [1/2]

QfDrawingStroke QfDrawingCanvas::currentStroke;

property frameColor [1/2]

QColor QfDrawingCanvas::frameColor;

This property holds the color of the canvas frame.


property isDirty [1/2]

bool QfDrawingCanvas::isDirty;

This property is set to TRUE when a created canvas has been modified.


property isEmpty [1/2]

bool QfDrawingCanvas::isEmpty;

This property is set to TRUE when no canvas has been created or a previously created canvas has been cleared.


property offset [1/2]

QPointF QfDrawingCanvas::offset;

This property holds the offset from the center of the canvas as a result of panning operations.


property zoomFactor [1/2]

double QfDrawingCanvas::zoomFactor;

This property holds the current zoom factor of the canvas. A value of 1.0 means the canvas is at native resolutio (i.e. one screen pixel represents one canvas pixel).


Public Signals Documentation

signal currentStrokeChanged

void QfDrawingCanvas::currentStrokeChanged;

signal frameColorChanged

void QfDrawingCanvas::frameColorChanged;

signal isDirtyChanged

void QfDrawingCanvas::isDirtyChanged;

signal isEmptyChanged

void QfDrawingCanvas::isEmptyChanged;

signal offsetChanged

void QfDrawingCanvas::offsetChanged;

signal zoomFactorChanged

void QfDrawingCanvas::zoomFactorChanged;

Public Functions Documentation

function QfDrawingCanvas

QfDrawingCanvas::QfDrawingCanvas (
    QQuickItem * parent=nullptr
) 

function clear

Q_INVOKABLE void QfDrawingCanvas::clear () 

Clears the drawing canvas.

See also: isEmpty()


function createBlankCanvas

Q_INVOKABLE void QfDrawingCanvas::createBlankCanvas (
    int width,
    int height,
    QColor backgroundColor=QColor(255, 255, 255)
) 

Creates a blank drawing canvas.

Parameters:

  • width the width of the canvas.
  • height the height of the canvas.
  • backgroundColor the background color of the canvas.

function createCanvasFromImage

Q_INVOKABLE void QfDrawingCanvas::createCanvasFromImage (
    const QString & path
) 

Creates a drawing canvas from a given image which will be the background on which the drawing will be overlayed.

Parameters:

  • path the image path.

function currentStroke [2/2]

QfDrawingStroke QfDrawingCanvas::currentStroke () const

function fitCanvas

Q_INVOKABLE void QfDrawingCanvas::fitCanvas () 

Fits the drawing canvas to match available width and height.


function frameColor [2/2]

QColor QfDrawingCanvas::frameColor () const

This property holds the color of the canvas frame.


function isDirty [2/2]

bool QfDrawingCanvas::isDirty () const

This property is set to TRUE when a created canvas has been modified.


function isEmpty [2/2]

bool QfDrawingCanvas::isEmpty () const

This property is set to TRUE when no canvas has been created or a previously created canvas has been cleared.


function offset [2/2]

QPointF QfDrawingCanvas::offset () const

This property holds the offset from the center of the canvas as a result of panning operations.


function paint

void QfDrawingCanvas::paint (
    QPainter * painter
) override

function pan

Q_INVOKABLE void QfDrawingCanvas::pan (
    const QPointF & oldPosition,
    const QPointF & newPosition
) 

Pans the drawing canvas by the distance between two points.


function save

Q_INVOKABLE QString QfDrawingCanvas::save () const

Saves the drawing canvas to a temporary location.

Returns:

the temporary file path of the saved image.


function setFrameColor

void QfDrawingCanvas::setFrameColor (
    const QColor & color
) 

This property holds the color of the canvas frame.


function setIsDirty

void QfDrawingCanvas::setIsDirty (
    bool dirty
) 

This property is set to TRUE when a created canvas has been modified.


function setIsEmpty

void QfDrawingCanvas::setIsEmpty (
    bool empty
) 

This property is set to TRUE when no canvas has been created or a previously created canvas has been cleared.


function setOffset

void QfDrawingCanvas::setOffset (
    const QPointF & offset
) 

This property holds the offset from the center of the canvas as a result of panning operations.


function setZoomFactor

void QfDrawingCanvas::setZoomFactor (
    double factor
) 

This property holds the current zoom factor of the canvas. A value of 1.0 means the canvas is at native resolutio (i.e. one screen pixel represents one canvas pixel).


function strokeBegin

Q_INVOKABLE void QfDrawingCanvas::strokeBegin (
    const QPointF & point,
    const QColor color=QColor(0, 0, 0)
) 

Begins a stroke operation.

Parameters:

  • point the first point of the stroke
  • color the color of the stroke

function strokeEnd

Q_INVOKABLE void QfDrawingCanvas::strokeEnd (
    const QPointF & point
) 

Ends the current stroke with a final point added to the stroke path.

Note:

The function strokeBegin must have been called prior to this function.


function strokeMove

Q_INVOKABLE void QfDrawingCanvas::strokeMove (
    const QPointF & point
) 

Adds a new point to the current stroke path.

Note:

The function strokeBegin must have been called prior to this function.


function undo

Q_INVOKABLE void QfDrawingCanvas::undo () 

Undos the last drawing operation.

See also: isDirty()


function zoom

Q_INVOKABLE void QfDrawingCanvas::zoom (
    double scale
) 

Zooms the drawing canvas by the provided scale value.


function zoomFactor [2/2]

double QfDrawingCanvas::zoomFactor () const

This property holds the current zoom factor of the canvas. A value of 1.0 means the canvas is at native resolutio (i.e. one screen pixel represents one canvas pixel).


function ~QfDrawingCanvas

QfDrawingCanvas::~QfDrawingCanvas () = default


The documentation for this class was generated from the following file src/core/qfdrawingcanvas.h