Qt widget that provides a drawing canvas.
More...
#include <drawingWidget.h>
|
| void | onDrawCommand (const nsbaci::types::DrawCommand &command) |
| | Handle a drawing command.
|
| void | onDrawRequested (const nsbaci::types::Drawable &drawable) |
| | Handle a drawable object.
|
| void | onClearRequested (const nsbaci::types::Color &color) |
| | Clear the canvas with a specific color.
|
|
void | onRefreshRequested () |
| | Refresh the canvas display.
|
| void | onCanvasSizeChanged (const nsbaci::types::Size &size) |
| | Handle canvas size change.
|
|
void | setColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
| | Set the current drawing color.
|
|
void | clear () |
| | Clear the canvas with the current background color.
|
|
void | drawCircle (int32_t centerX, int32_t centerY, int32_t radius, bool filled=false) |
| | Draw a circle.
|
|
void | drawRectangle (int32_t x, int32_t y, int32_t width, int32_t height, bool filled=false) |
| | Draw a rectangle.
|
|
void | drawTriangle (int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, bool filled=false) |
| | Draw a triangle.
|
|
void | drawLine (int32_t x1, int32_t y1, int32_t x2, int32_t y2) |
| | Draw a line.
|
|
void | drawEllipse (int32_t centerX, int32_t centerY, int32_t radiusX, int32_t radiusY, bool filled=false) |
| | Draw an ellipse.
|
|
void | drawPixel (int32_t x, int32_t y) |
| | Draw a pixel.
|
|
void | drawText (int32_t x, int32_t y, const QString &text, int32_t fontSize=12) |
| | Draw text.
|
|
void | setLineWidth (int32_t width) |
| | Set the line width.
|
|
void | reset () |
| | Reset the widget to initial state.
|
|
| void | paintEvent (QPaintEvent *event) override |
| | Paint event handler.
|
| void | resizeEvent (QResizeEvent *event) override |
| | Resize event handler.
|
Qt widget that provides a drawing canvas.
The DrawingWidget maintains a pixel buffer (QPixmap) where all drawing operations are performed. It supports various shapes, colors, and provides a persistent canvas that preserves drawings between repaints.
◆ DrawingWidget()
| nsbaci::ui::DrawingWidget::DrawingWidget |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs the drawing widget.
- Parameters
-
| parent | Optional parent widget. |
◆ getCanvasSize()
Get the current canvas size.
- Returns
- The canvas size.
◆ minimumSizeHint()
| QSize nsbaci::ui::DrawingWidget::minimumSizeHint |
( |
| ) |
const |
|
override |
Get the minimum size hint for the widget.
- Returns
- The minimum size.
◆ onCanvasSizeChanged
Handle canvas size change.
- Parameters
-
◆ onClearRequested
Clear the canvas with a specific color.
- Parameters
-
| color | The background color. |
◆ onDrawCommand
Handle a drawing command.
- Parameters
-
| command | The command to execute. |
◆ onDrawRequested
Handle a drawable object.
- Parameters
-
| drawable | The drawable to render. |
◆ paintEvent()
| void nsbaci::ui::DrawingWidget::paintEvent |
( |
QPaintEvent * | event | ) |
|
|
overrideprotected |
Paint event handler.
- Parameters
-
◆ resizeEvent()
| void nsbaci::ui::DrawingWidget::resizeEvent |
( |
QResizeEvent * | event | ) |
|
|
overrideprotected |
Resize event handler.
- Parameters
-
◆ sizeHint()
| QSize nsbaci::ui::DrawingWidget::sizeHint |
( |
| ) |
const |
|
override |
Get the size hint for the widget.
- Returns
- The preferred size.
The documentation for this class was generated from the following files: