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:
Qt Code:
  1. w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
To copy to clipboard, switch view to plain text mode 
And to come back
Qt Code:
  1. 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)
Qt Code:
  1. void mousePressEvent(QMouseEvent*) {
  2. if (maxMode== false)
  3. {
  4. m_enOrigWindowFlags = this->windowFlags();
  5. m_pSize = this->size();
  6. this->setParent(0);
  7. this->setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
  8. this->showFullScreen();
  9. maxMode = true;
  10. }
  11. else
  12. {
  13. this->setParent(m_pParent);
  14. this ->resize(m_pSize);
  15. this->overrideWindowFlags(m_enOrigWindowFlags);
  16. this->show();
  17. maxMode = false;
  18. }
  19. }
  20. };
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!