Reputation: 2238
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() )
showNormal();
else
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.
Upvotes: 2
Views: 1279
Reputation: 1058
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.
Upvotes: 0