Factory method to generate standard or custom cursor.
19{
20
21
24 int halfSize = size / 2;
26 int halfLineWidth = lineWidth / 2;
27
29
30
31 return QCursor (Qt::CrossCursor);
32
33 } else {
34
35
36 const int BACKGROUND_COLOR = Qt::white, FOREGROUND_COLOR = Qt::black;
37
38
39
40 QPixmap picMask (size,
41 size);
42 QPainter picMaskPaint (&picMask);
43 picMask.fill (QColor (BACKGROUND_COLOR));
44
45 QPen pen (QBrush (FOREGROUND_COLOR),
47 picMaskPaint.setPen (pen);
48
49 picMaskPaint.drawLine (QPointF (halfSize,
50 halfSize - innerRadius - halfLineWidth),
51 QPointF (halfSize,
52 lineWidth));
53 picMaskPaint.drawLine (QPointF (halfSize - innerRadius - halfLineWidth,
54 halfSize),
55 QPointF (lineWidth,
56 halfSize));
57 picMaskPaint.drawLine (QPointF (halfSize,
58 halfSize + innerRadius + halfLineWidth),
59 QPointF (halfSize,
60 size - 1 - lineWidth));
61 picMaskPaint.drawLine (QPointF (halfSize + innerRadius + halfLineWidth,
62 halfSize),
63 QPointF (size - 1 - lineWidth,
64 halfSize));
65
66 QPixmap pic (size,
67 size);
68 pic.fill (QColor (FOREGROUND_COLOR));
69
70 return QCursor (pic.createMaskFromColor(QColor (BACKGROUND_COLOR)),
71 picMask.createMaskFromColor(QColor (BACKGROUND_COLOR)));
72 }
73}
int CursorSizeToPixels(CursorSize cursorSize)
CursorSize cursorSize() const
Get method for cursor size.
int cursorInnerRadius() const
Get method for cursor inner radius.
bool cursorStandardCross() const
Get method for cursor type.
int cursorLineWidth() const
Get method for cursor line width.