Is there a "layout complete" event?

  • I am making a simple multi-page document viewer. I have an initially empty QScrollArea, to whose layout I add
    several (or many) QLabel widgets. I create and size these QLabels and add them to the layout in a loop, which does not take long.

    The problem is that right after this, I try and determine which ones are visible within the QScrollArea using
    visibleRegion(), but none of them appear visible. If, however, I go away for 200 msec (using a QTimer)
    and try again, I then get the results I expect.

    So, question: how can I determine exactly when the sizing/layout of these QLabels is actually done?


  • Lifetime Qt Champion


    You could use the showEvent method from your QScrollArea container.

  • Thanks for your reply. I was able to put an event filter on the scroll area's content widget, and watch for QEvent::LayoutRequest.

  • Lifetime Qt Champion

    Nice, but AFAIK, that event means that the layout should be updated, not that it has already happened

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.