Important: Please read the Qt Code of Conduct -

QFrame: Why do i need paint twice to be able to see it?

  • Hello. I've attached a project. It can be useful:
    It creates a spash screen ( with transparent PNG ) and starts loading things.
    ( reading settings, allocating memory, setting up dialogs, windows...... these are not included but easily can be done )

    During loading through a text buffer it tells the user what's going on. When finished opens up the mainwindow.

    My problem is that i have to paint twice and only after then emit the showed() function, which will start the initialization. Why is that? If in first paintEvent() i call emit showed() I can't see the painted QFrame. But one paint is done, isn't it?

    A few pics:

    This is how I solved it, but I don't understand the why... it should work first time...:
    in paintEvent() function:
    itsShowed = 0;
    if( itsShowed < 2 ){
    if( itsShowed == 2 ) emit showed();

    If i only put
    @emit showed();@
    in the paintEvent() function, i could only see the window appear after the initialization, but then it's closed right away. So no SplashScreen at all. Why?

Log in to reply