Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (34 sloc) 1003 Bytes
#include "startbutton.h"
#include <QGraphicsTextItem>
#include <QBrush>
StartButton::StartButton(QString name, QGraphicsItem *parent): QGraphicsRectItem (parent)
{
setRect(0,0,200,50);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::darkCyan);
setBrush(brush);
text = new QGraphicsTextItem(name, this);
int xPos = rect().width()/2 - text->boundingRect().width()/2;
int yPos = rect().height()/2 - text->boundingRect().height()/2;
text->setPos(xPos, yPos);
setAcceptHoverEvents(true);
}
void StartButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
emit clicked();
}
void StartButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::cyan);
setBrush(brush);
}
void StartButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::darkCyan);
setBrush(brush);
}