Qwidget height() and width() changing
-
I'm trying to learn how to draw using QPainter. I'm basing the renderarea class off the basic drawing example. I'm making a QPainterPath with this
@ void RenderArea::Path()
{
path.moveTo(150,0);
path.lineTo(150,height());
update();
}@and then
@
void RenderArea::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
painter.drawPath(path);
}
@
The issue is that when I click the push button that triggers Path(), the first time it runs, the line does not extend the entire height of the renderarea widget. The same happens if I try to draw across using width(). However, if I click the push button again, height() and width() will extend across the widget as expected. What am I missing? I don't understand why height() and width() change.