I want to make my QVideoWidget fullscreen on mouse click and back.
I've implemented the mouse click and have tried two methods to go fullscreen but both are not working.
Method 1:
w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
To copy to clipboard, switch view to plain text mode
And to come back
w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
To copy to clipboard, switch view to plain text mode
Nothing happens in this case.
Method 2: (found after some good internet searching)
if (maxMode== false)
{
m_enOrigWindowFlags = this->windowFlags();
m_pSize = this->size();
this->setParent(0);
this->setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
this->showFullScreen();
maxMode = true;
}
else
{
this->setParent(m_pParent);
this ->resize(m_pSize);
this->overrideWindowFlags(m_enOrigWindowFlags);
this->show();
maxMode = false;
}
}
};
void mousePressEvent(QMouseEvent*) {
if (maxMode== false)
{
m_enOrigWindowFlags = this->windowFlags();
m_pSize = this->size();
this->setParent(0);
this->setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
this->showFullScreen();
maxMode = true;
}
else
{
this->setParent(m_pParent);
this ->resize(m_pSize);
this->overrideWindowFlags(m_enOrigWindowFlags);
this->show();
maxMode = false;
}
}
};
To copy to clipboard, switch view to plain text mode
This method works fine to get to fullscreen. But on the second click the video widget comes in a new window and not on the original position on the Ui.
Please help me. Thanks!
Bookmarks