QVideoWidget is new window after leaving fullscreen

I want my video player to show the QVideoWidget fullscreen when double clicking. I have created a new class, inherited the QVideoWidget class and I then overwritten the mousDoubleClickEvent.

//Mouse event in new VideoWidget Class
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
    if( isFullScreen() )
        setFullScreen( true ); //Show in fullscreen

The VideoWidget is used in my main window where (later) all other widgets are placed.

void MainWindow::setupUi()
    QWidget* centralWidget = new QWidget( this );
    QHBoxLayout* centralLayout = new QHBoxLayout( centralWidget );

    videoWidget = new VideoWidget( this );

    setCentralWidget( centralWidget );
    centralLayout->addWidget( videoWidget );

The problem is now that whenver I enter the full screen mode by double click and exit again by double click, the video widget is no longer in the MainWindow. It is a new window. How do I place it back to its old position again?

Edit: The videoWidget seems to be in a new window AND in my centralLayout. But when I close the new window it disappears in my centralLayout too.


I think video widget is being detached from main window when toggling fullscreen. Maybe you should try to re-add it to layout manually after returning to normal mode.

Need Your Help

Typescript build Sublime Text 3 on Linux - [Errno 20] Not a directory

linux typescript sublimetext sublimetext3

Trying to make build system for TypeScript working on Sublime Text 3 on Ubuntu.

How do I integrate GUI elements from different classes at runtime?

java user-interface swing

I'm trying to "future-proof" an application that I'm writing by splitting out those elements that are likely to change over time. In my application I need to be able to adapt to changes in the output