When window goes fullscreen, show something different
-
Do you see the window title of that black window? Or anything which identifies the black window, so you can see where it actually comes from?
@pl45m4
No I cannot see the title bar nor the menu bar.There can be a lot of fullscreen windows because each window then is getting its „own desktop“.
My thoughts were that the black view and the QMainWindow are in real one piece and result in a fullscreen QMainWindow. I tried
repaint
on it but this does not work. -
@pl45m4
No I cannot see the title bar nor the menu bar.There can be a lot of fullscreen windows because each window then is getting its „own desktop“.
My thoughts were that the black view and the QMainWindow are in real one piece and result in a fullscreen QMainWindow. I tried
repaint
on it but this does not work. -
Ok, the "own-desktop"-thing is Mac related (I'm not a mac-expert)
What happens if you set only the MainWindow to fullscreen without the new widget? Do you get a black screen on one virtual desktop too?
-
I am now 100% sure the black view has something to do with my application. When I move into the "desktop overview" I can see that the black view has the name of my application. So its probably that the QMainWindow does not gets painted.
I think I know what the problem is and that is on the side of macOS. When I call just
show
my new QWidget is just showing up without any mistakes (but not in fullscreen). The problem here is probably that I try to launch another window in fullscreen while I am in fullscreen. So the solution to that would be catching up before we go fullscreen. But as I think there's no Qt solution to that, or am I wrong? -
BOOM, I got this!
void MainWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::WindowStateChange) { Qt::WindowStates state = this->windowState(); // debug reasons if (this->windowState() == Qt::WindowFullScreen) { appIsFs = true; showEditViewFs(); } } } void MainWindow::showEditViewFs() { if (appIsFs == true) { fsWindow->show(); fsWindow->setWindowState(windowState() & Qt::WindowFullScreen); this->setWindowState(windowState() & ~(Qt::WindowFullScreen)); } }
@Pl45m4 Now I am hanging here at the point that it just ignores the
this->setWindowState(windowState() & ~(Qt::WindowFullScreen));
. -
BOOM, I got this!
void MainWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::WindowStateChange) { Qt::WindowStates state = this->windowState(); // debug reasons if (this->windowState() == Qt::WindowFullScreen) { appIsFs = true; showEditViewFs(); } } } void MainWindow::showEditViewFs() { if (appIsFs == true) { fsWindow->show(); fsWindow->setWindowState(windowState() & Qt::WindowFullScreen); this->setWindowState(windowState() & ~(Qt::WindowFullScreen)); } }
@Pl45m4 Now I am hanging here at the point that it just ignores the
this->setWindowState(windowState() & ~(Qt::WindowFullScreen));
.@l1psync
question, why do you make your 2nd Window as Independent window?Let the QMainWindow go fullscreen, detect that, and simply exchange the content of or QMainWindow.
You can do that for example via setContentWidget, make sure to keep a valid pointer of your original contentWidget to realign it, once the fullscreen exits
-
@l1psync
question, why do you make your 2nd Window as Independent window?Let the QMainWindow go fullscreen, detect that, and simply exchange the content of or QMainWindow.
You can do that for example via setContentWidget, make sure to keep a valid pointer of your original contentWidget to realign it, once the fullscreen exits
-
@l1psync said in When window goes fullscreen, show something different:
@j-hilk Good point, you mean
setCentralWidget()
Yes, of course. Too much QML lately ;)
https://doc.qt.io/qt-5/qmainwindow.html#setCentralWidget -
Hi,
QStackedWidget comes to mind for that.