25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
773 B

  1. #include "graphicsitems.h"
  2. #include <QPainter>
  3. // 可调整大小的矩形(按钮)实现
  4. ResizableRectangle::ResizableRectangle(qreal x, qreal y, qreal w, qreal h)
  5. : ResizableShape<QGraphicsRectItem>(x, y, w, h)
  6. {
  7. m_name = "按钮";
  8. m_pressedColor = Qt::green;
  9. m_releasedColor = Qt::yellow;
  10. this->setBrush(m_releasedColor);
  11. }
  12. // 可调整大小的椭圆(指示灯)实现
  13. ResizableEllipse::ResizableEllipse(qreal x, qreal y, qreal w, qreal h)
  14. : ResizableShape<QGraphicsEllipseItem>(x, y, w, h)
  15. {
  16. m_name = "指示灯";
  17. m_onColor = Qt::green;
  18. m_offColor = Qt::red;
  19. this->setBrush(m_onColor);
  20. }
  21. // 显式实例化模板类
  22. template class ResizableShape<QGraphicsRectItem>;
  23. template class ResizableShape<QGraphicsEllipseItem>;