Important: Please read the Qt Code of Conduct -

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()

    and then
    void RenderArea::paintEvent(QPaintEvent * /* event */)
    QPainter painter(this);
    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.

Log in to reply