#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QMouseEvent>
#include <QToolTip>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
setMouseTracking(true);
}
Widget::~Widget()
{
delete ui;
}
void Widget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawLine(QPoint(0,0),QPoint(100,100));
QPen pen(Qt::yellow,3,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin);
painter.setPen(pen);
QRect rectangle(70,40,600,600);
int startangle = 0*16;
int spanangle = 360*16;
painter.drawArc(rectangle,startangle,spanangle);
QConicalGradient conicalGradient(QPointF(350,190),90);
conicalGradient.setColorAt(0,Qt::black);
conicalGradient.setColorAt(0.5,Qt::red);
painter.setBrush(conicalGradient);
painter.drawEllipse(QPoint(350,190),50,50);
}
void Widget::mouseMoveEvent(QMouseEvent *event)
{
QString pos = QString("%1,%2").arg(event->pos().x()).arg(event->pos().y());
QToolTip::showText(event->globalPos(),pos,this);
}