Good Day,
//I'm fairly proficient in qt -> got some problems with interactive programming as:
1) I created a simple label
2) Uploaded Image to Label
3) using mouseEvents & paintEvent was able to create point on Image
4) MY PROBLEM: the 2nd mouse click! //& store 2nd point where?
User needs to click twice to get 2 points(line will be drawn between them, however everytime in the running program! when I click for a second time, the initial point becomes the new point.
some att code:
void label::mousePressEvent(QMouseEvent *event)
{
paintFlag = 0;
if(event->button()==Qt::LeftButton)
{
this->x = ev->x();
this->y = ev->y();
//store 1st point
x1 = x;
y1 = y;
emit Mouse_Pressed();
paintFlag = 1;
//Mouse Pressed Again! 2nd point
x2 = x;
y2 = y;
emit Mouse_Pressed();
}
}
paintEvent:
QPainter painter(this);
QPen paintpen(Qt::red);
paintpen.setWidth(4);
QPoint p1;
p1.setX(x1);
p1.setY(y1);
painter.setPen(paintpen);
painter.drawPoint(p1);
}
Any ideas on my problem... what am i not seeing!
Thanks
Bookmarks