I am using this code to toggle a window from normal mode to fullscreen:
void MainWindow::on_action_Fullscreen_triggered()
{
showFullScreen();
}
How to return back to normal mode when I trigger this action again?
I am using this code to toggle a window from normal mode to fullscreen:
void MainWindow::on_action_Fullscreen_triggered()
{
showFullScreen();
}
How to return back to normal mode when I trigger this action again?
The answer of LogicStuff is almost perfect but it does not account for whether the window was maximized or not. Personally I always use this little snippet:
void main_window::toggle_fullscreen()
{
isFullScreen() ?
((was_maximized_) ? showMaximized() : showNormal()), ui_->menu_view_toggle_fullscreen->setIcon(QIcon(":/fullscreen_enter")) :
((was_maximized_ = isMaximized()), showFullScreen(), ui_->menu_view_toggle_fullscreen->setIcon(QIcon(":/fullscreen_exit")));
}
Since showFullScreen() also affects the isMaximized() return value, we have to save it somewhere (was_maximized_) before going full screen.
After a minute session with Qt's reference:
void MainWindow::on_action_Fullscreen_triggered()
{
isFullScreen() ? showNormal() : showFullScreen();
}