How to make a rectangles filled with horizontal lines in a QGraphicsView?
Unsolved
General and Desktop
-
How to make a rectangle filled with horizontal lines in a
QGraphicsView
for example as follows?_________________________ |-----------------------------------| |---------------------------------- | |---------------------------------- | | ---------------------------------- | | ---------------------------------- | | ---------------------------------- | | ----------------------------------| |------------------------------------
-
Hi! Create a custom QGraphicsItem-derived class, override
boundingRect()
andpaint()
, draw the background, draw the lines with a dashed pen style.- QGraphicsItem Class, see example under #details
- QPainter Class
- QPen
- enum Qt::PenStyle
- QBrush
- enum Qt::BrushStyle
- Basic Drawing Example
-
@Qt-Enthusiast
Depending on what exactly you want, it may be sufficient to apply the correct brush. -
could you elaborate with the QBrush color style
-
@Qt-Enthusiast
Create a QBrush and set the style to Qt::HorPatternmyBrush.setStyle(Qt::HorPattern)
Then apply the brush to a rectangle. You can see the result in the Basic Drawing example.