Good Day,
I'm struggling with resizing my paint event!
In my constructor:
QLabel(parent
), windowSize
(333,
494) {...
rect.
setTopLeft(QPoint(9,
9));
rect.setSize(windowSize);
setGeometry(rect);
}
qLabel::qLabel(QWidget *parent) :
QLabel(parent), windowSize(333, 494)
{...
QRect rect;
rect.setTopLeft(QPoint(9, 9));
rect.setSize(windowSize);
setGeometry(rect);
}
To copy to clipboard, switch view to plain text mode
In my paint event
{
qreal sx = ev->rect().width() / (qreal)windowSize.width();
qreal sy = ev->rect().height() / (qreal)windowSize.height();
painter.scale(sx, sy);
...
//draw points and lines between every 2 consective points
}
void mmetLabel::paintEvent(QPaintEvent *ev)
{
QLabel::paintEvent(ev);
QPainter painter(this);
qreal sx = ev->rect().width() / (qreal)windowSize.width();
qreal sy = ev->rect().height() / (qreal)windowSize.height();
painter.scale(sx, sy);
...
//draw points and lines between every 2 consective points
}
To copy to clipboard, switch view to plain text mode
Once I click on my label, I display the coordinates of the mouse ->working
Label also displays the 1st point and 2nd point coordinates -> working
My Paintevent -> NOT Working accordingly
It draws points not where mouse is clicked, hence the lines are completely not right
example, If I click at point1 (x=100, y=100) & click point2(x=152, y=251)
it draws a line from (x=230, y=128) -> (x=351, y=195) = completely wrong!
Please help
Kind Regards
Previous Thread(Title: Re: Paint event does not Rescale with label maximise)
Bookmarks