|
- #include "button.h"
- #include <QPainter>
- #include <QStyleOptionGraphicsItem>
-
- Button::Button(const QString &type) : Item(type)
- {
-
- }
-
- QRectF Button::boundingRect() const
- {
- return QRectF(0, 0, 50, 50);
- }
-
- void Button::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
- {
- painter->setRenderHint(QPainter::Antialiasing);
-
- if (type_ == "按钮") {
- painter->drawRect(0,0,50,50);
- }
- if (option->state & QStyle::State_Selected) {
- QPen pen(Qt::DashLine);
- pen.setColor(Qt::blue);
- pen.setWidth(2);
- painter->setPen(pen);
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(boundingRect());
- }
- }
|