Important: Please read the Qt Code of Conduct -

Custom Widget Paint Event Too Soon?

  • I'm writing a custom widget, and it appears to be getting a really early paintEvent() call before its proper size has been set by the layout it's in, causing it to flash up on the screen really large before being immediately resized to the correct dimensions. I'm clearly missing a standard widget procedural step during initialization, but what is it?

  • Do you happen to call show() before you put it into the layout?

  • Ah. Yes indeed, through a long, convoluted series of function calls that certainly should not be calling show(). I wonder why I put that in there? Thanks for the kick.

Log in to reply