I want to highlight all the pixels where cursor moved after entering the widget and before leaving it.
On reimplementing the paintEvent and using drawPoint, I am able to display the current cursor position. But I dont want old points to disappear. How do i keep all previous points also highlighted???
I am not successful in using drawPath and drawPoints for this.
ui(new Ui::Lines)
{
ui->setupUi(this);
}
{
drawLines(&qp);
}
{
QPen pen2
(Qt
::red,
8, Qt
::SolidLine);
qp->setPen(pen2);
int x;
int y;
x = p.x();
y= p.y();
qp->drawPoint(p);
this->update();
}
Lines::Lines(QWidget *parent) :
QWidget(parent),
ui(new Ui::Lines)
{
ui->setupUi(this);
}
void Lines::paintEvent(QPaintEvent *e)
{
QPainter qp(this);
drawLines(&qp);
}
void Lines::drawLines(QPainter *qp)
{
QPen pen2(Qt::red, 8, Qt::SolidLine);
qp->setPen(pen2);
int x;
int y;
QPoint p = QCursor::pos();
x = p.x();
y= p.y();
qp->drawPoint(p);
this->update();
}
To copy to clipboard, switch view to plain text mode
Bookmarks