Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

38 строки
1.2 KiB

  1. #ifndef BUTTON_H
  2. #define BUTTON_H
  3. #include "item.h"
  4. class Button : public Item
  5. {
  6. public:
  7. Button(const QString &type);
  8. QRectF boundingRect() const override;
  9. void paint(QPainter *painter,
  10. const QStyleOptionGraphicsItem *option,
  11. QWidget *) override;
  12. void addMenuActions(QMenu *menu) override;
  13. void handleMenuAction(QAction *action) override;
  14. void setCustomImage(const QString& imagePath);
  15. void setCurrentSize(QSizeF size);
  16. QSizeF currentSize();
  17. QString imagePath();
  18. void loadImage();
  19. // 鼠标事件处理
  20. void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
  21. void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
  22. void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
  23. private:
  24. QString imagePath_;
  25. QPixmap customPixmap_;
  26. bool resizing_ = false; // 是否正在调整大小
  27. QPointF resizeStartPos_; // 调整大小开始位置
  28. QSizeF originalSize_; // 调整前的原始大小
  29. QSizeF currentSize_ = QSizeF(50, 50); // 当前实际尺寸
  30. int resizeHandleSize_ = 8; // 调整手柄大小
  31. int resizeMargin_ = 5; // 调整边距
  32. };
  33. #endif // BUTTON_H