Full screen osx Widget - Works the first time then fails.



  • I have taken over a project that has a video player, it includes the capability to switch to full screen. On OS X the full screen switch works as expected. If I switch from full screen back to the normal size screen, then attempt to switch back to full screen.
    The widget is removed from its parent (expected). But instead of full screen its now displayed the same size as the original but now in the upper left hand side of the display (detached from our app).

    When we switch to full screen we set the widget parent to 0 then set full screen. The second time we attempt to switch to full screen the "parent switch" clearly works but the action to switch to full screen is failing for some unknown reason.

    Note: If we run this app on a windows machine it works perfectly.

    @
    void VideoPlayerWidget::setFullScreen(bool entering)
    {
    if(entering == true)
    {
    ui.frameVideoHeader->hide();
    ui.buttonFullScreenMode->hide();
    emit enterFullScreen();
    }
    else
    {
    ui.frameVideoHeader->show();
    ui.buttonFullScreenMode->show();
    emit exitFullScreen();
    }
    }
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]



  • Ok, I solved the problem but would be interested if anyone could provide me with an explanation.

    What I found was when the emit fullscreen is called and the windows state the first time (successful full screen) the widget window state is - Qt::WindowNoState. After reverting back to "normal size" the second call to enterFullScreen. The windows state was Qt::WindowFullScreen which is not correct.

    To fix my problem I added the line

    @
    if(this->windowState()==4)
    this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
    @

    to force the window state.
    After adding this line the full screen/normal screen switch works as expected every time.

    @
    // SIGNAL 0
    void VideoPlayerWidget::enterFullScreen()
    {
    if(this->windowState()==4) this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
    QMetaObject::activate(this, &staticMetaObject , 0, 0);

    }
    @

    [EDIT: code formatting, Volker]


Log in to reply
 

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