-
-
-class QGraphicsRectHandleItem: public QGraphicsRectItem
-{
-public:
-
- QGraphicsRectHandleItem(const QRectF & rect, QGraphicsItem * parent = 0):
- QGraphicsRectItem(rect, parent),
- drawHandles(false) {
- }
-
- bool drawHandles;
-
-
- virtual void paint(QPainter *painter,
- const QStyleOptionGraphicsItem * option,
- QWidget* widget = 0) {
- QGraphicsRectItem::paint(painter, option, widget);
- if (!drawHandles) return;
- double handleSize = 6 / painter->matrix().m11();
- painter->fillRect(0, 0, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - handleSize, 0, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - handleSize, option->rect.height() - handleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(0, option->rect.height() - handleSize, handleSize, handleSize, QColor(Qt::yellow));
- }
-};