#include "cudlik.h"
#include <QPainter>
#include <QMouseEvent>
#include <QPushButton>
{
setText(text);
setMouseTracking(true);
}
Cudlik::~Cudlik()
{
}
{
painter
->setRenderHint
(QPainter::Antialiasing);
painter->setPen(farba);
painter
->setBrush
(QBrush(farba
));
painter->drawText(10,10,text());
delete painter;
}
{
QPoint kurzor
= event
->globalPos
();
if (kurzor.x()<napis.x() || kurzor.x()>napis.x()+width() || kurzor.y()<napis.y() || kurzor.y()>napis.y()+height())
{
//update();
}
else
{
update();
}
}
{
move(x()+2,y()+4);
update();
}
{
move(x()-2,y()-4);
emit clicked();
update();
}
#include "cudlik.h"
#include <QPainter>
#include <QMouseEvent>
#include <QPushButton>
Cudlik::Cudlik(const QString & text, QPushButton *parent)
: QPushButton(parent)
{
setText(text);
farba=(QColor(37,123,218));
setMouseTracking(true);
}
Cudlik::~Cudlik()
{
}
void Cudlik::paintEvent(QPaintEvent *event)
{
painter = new QPainter(this);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(farba);
painter->setBrush(QBrush(farba));
painter->drawText(10,10,text());
delete painter;
}
void Cudlik::mouseMoveEvent(QMouseEvent* event)
{
QPoint kurzor = event->globalPos();
QPoint napis = pos();
if (kurzor.x()<napis.x() || kurzor.x()>napis.x()+width() || kurzor.y()<napis.y() || kurzor.y()>napis.y()+height())
{
farba=(QColor(37,123,218));
//update();
}
else
{
farba=(QColor(108,203,52));
update();
}
}
void Cudlik::mousePressEvent(QMouseEvent* event)
{
farba=QColor(238,105,17);
move(x()+2,y()+4);
update();
}
void Cudlik::mouseReleaseEvent(QMouseEvent* event)
{
move(x()-2,y()-4);
emit clicked();
update();
}
To copy to clipboard, switch view to plain text mode
Bookmarks