learner_qt
8th February 2013, 06:09
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. :(
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();
}
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. :(
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();
}