0

With my code when I double click the video it enters fullscreen but seems to open up an entirely new window on my other monitor. When I try to double click the new fullscreen window to exit it doesn't exit but if I go to my other monitor and double click where the videowidget is supposed to be it closes the fullscreen window. How to I fix this?

GitHub

Before FullScreen

https://gyazo.com/f56b4e4d00dda722be6beec9bfff7e19 (After FullScreen) Needed to use a Gyazo link because the file size was too large as I am screenshotting both monitors. Code I've Tried->

void MainWindow::keyPressEvent(QKeyEvent *event){
if ((event->key() == Qt::Key_Escape || event->key() == Qt::Key_Back) ) {
    if( vw->isFullScreen() != true){
        vw->setFullScreen(true);
    } else(showNormal());
}}

void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) {
 if( vw->isFullScreen() != true){
     vw->setFullScreen(true);
 } else(vw->setFullScreen(false)); }

void MainWindow::on_fullScreen_clicked(){ if( vw->isFullScreen() != true){
    vw->setFullScreen(true); } else(vw->setFullScreen(false));}
Dualists
  • 11
  • 3
  • I do not know the reason why your code does not work because there is missing lots of information. E.g. what is `vw` and why you do not "fullscreen-ize" your main window (i.e. `this`) instead of this mysterious `vw`... Also you do not show how the slot `on_fullScreen_clicked` is wired to the rest of the code; btw. what happens if you remove this slot? But why don't you write `vw->setFullScreen(!vw->isFullScreen())` instead of those ugly `if-else`s? – HiFile.app - best file manager Sep 29 '22 at 08:26
  • My advice would be to remove `on_fullScreen_clicked()` completely because it probably conflicts with the double click event handler when in fullscreen mode. And then write double click event handler like this: `void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) { setFullscreen(!isFullScreen()); }` and that's it. Note that I removed `vw` but I call the `setFullScreen` on the main window. This super simple solution should work just fine. – HiFile.app - best file manager Sep 29 '22 at 08:34
  • 1
    Please provide [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) so we can run and test it. If you add your code to the GitHub repo we can test it and fix it for you else please create [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) , I can't understand what makes that issue. – Parisa.H.R Sep 29 '22 at 12:40
  • Here is the GitHub link, https://github.com/AdamElt/AtomMediaPlayer – Dualists Oct 03 '22 at 21:44
  • The vw stands for the QVideoWidget. I changed the if else statements to vw->setFullScreen(!vw->isFullScreen()) but the problems still continues. I looked into it and it seems that for windows when you do the FullScreen command it opens an entirely new window. I am still not sure how to get around this. – Dualists Oct 03 '22 at 21:47
  • It seems that when it opens the fullscreen version the main window becomes out of focus so even if I use the escape key that would normally toggle fullscreen on or off, it can't doesn't work because it's out of focus. I've tried setting the main window and the GroupBox in StrongFocus but still nothing. – Dualists Oct 04 '22 at 01:18

0 Answers0