KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
LineGraphicsItem Class Reference

QGraphicsLineItem with an application-defined type integer and appearance helpers. More...

#include <linegraphicsitem.h>

+ Inheritance diagram for LineGraphicsItem:
+ Collaboration diagram for LineGraphicsItem:

Public Member Functions

 LineGraphicsItem (int type, QGraphicsItem *parent=nullptr)
 Construct with a type integer and optional parent item.
 
 LineGraphicsItem (const Line &line, int type, QGraphicsItem *parent=nullptr)
 Construct from a Line geometry object, with a type integer and optional parent.
 
virtual int type () const override
 Return the application-defined type integer.
 
void setWidth (double width)
 Set the pen width.
 
void setColor (const QColor &color)
 Set the pen color.
 
virtual QRectF boundingRect () const override
 Return the bounding rectangle (expanded to account for pen width).
 
virtual QPainterPath shape () const override
 Return the shape used for hit testing.
 
void setLength (double length)
 Set the length of the line, extending from its current start point.
 

Detailed Description

QGraphicsLineItem with an application-defined type integer and appearance helpers.

LineGraphicsItem stores a type integer (returned by type()) that allows qgraphicsitem_cast<> and scene item-type filtering to work with custom types. It also provides helpers for changing pen width, color, and line length.

Definition at line 15 of file linegraphicsitem.h.

Constructor & Destructor Documentation

◆ LineGraphicsItem() [1/2]

LineGraphicsItem::LineGraphicsItem ( int  type,
QGraphicsItem *  parent = nullptr 
)

Construct with a type integer and optional parent item.

Parameters
typeApplication-defined graphics item type
parentOptional parent QGraphicsItem

◆ LineGraphicsItem() [2/2]

LineGraphicsItem::LineGraphicsItem ( const Line &  line,
int  type,
QGraphicsItem *  parent = nullptr 
)

Construct from a Line geometry object, with a type integer and optional parent.

Parameters
lineLine geometry to display
typeApplication-defined graphics item type
parentOptional parent QGraphicsItem

Member Function Documentation

◆ boundingRect()

virtual QRectF LineGraphicsItem::boundingRect ( ) const
overridevirtual

Return the bounding rectangle (expanded to account for pen width).

Returns
Bounding rect in item coordinates

◆ setColor()

void LineGraphicsItem::setColor ( const QColor &  color)

Set the pen color.

Parameters
colorColor to apply to the pen

◆ setLength()

void LineGraphicsItem::setLength ( double  length)

Set the length of the line, extending from its current start point.

Parameters
lengthNew length in scene units

◆ setWidth()

void LineGraphicsItem::setWidth ( double  width)

Set the pen width.

Parameters
widthPen width in scene units

◆ shape()

virtual QPainterPath LineGraphicsItem::shape ( ) const
overridevirtual

Return the shape used for hit testing.

Returns
Painter path representing the clickable area

◆ type()

virtual int LineGraphicsItem::type ( ) const
inlineoverridevirtual

Return the application-defined type integer.

Returns
Item type value

Definition at line 37 of file linegraphicsitem.h.


The documentation for this class was generated from the following file: