Hi. I have a class MyView : public QGraphicsView which has a member function reposition_view() which calls fitInView(...) with arguments computed from the current state.

I call reposition_view() in the constructor, and again as the result of a slot method being called to update a relevant parameter.

After MyView has been constructed, the viewport transformation appears to have not applied -- e.g. a 30x50 (in world space) rectangle at the origin is drawn 30x50 pixels in screen space even if reposition_view dicates it should fill the window (and yes, it is being called with the correct arguments). Bizzarely, sometimes the Y axis is scaled correctly but X is untransformed.

As soon as reposition_view() is called again as the result of user interaction trigering a parameter change, the rendering is immediately correct. (Even if the arguments haven't changed.)

I presumed this was something to do with parent class layouts and show rules and blah and stuff, so I experimentially attached reposition_view() to a QTimer::singleShot. This works, but only if the delay is unacceptably large (500ms) else it works inconsistently (N.B. fitInView is the only QGraphicsView method which is called as a result, and that's with the same arguments as previousy). I also tried to trigger reposition_view() from a posted custom QEvent, but that had no effect.

What is the correct way to update the world->device transformation so that everything is correct before the widget is even drawn?

Thanks for reading.