Hide and show again fullscreen window
-
What is the expected behavior of the window state when hiding fullscreen window: can flags Qt::WindowFullScreen and Qt::WindowMaximized be changed?
Simple application with one button, that hides and shows fullscreen window and print FullScreen and Maximized flags:
@
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QWidget>
#include <QDebug>
#include <QHBoxLayout>class MainWindow : public QMainWindow
{
public:
explicit MainWindow(QWidget *parent = 0) : QMainWindow(parent) {
QPushButton *btn = new QPushButton("hideshow");
connect(btn, &QPushButton::clicked, = {
hide();
show();
qDebug() << isFullScreen() << isMaximized();
});
layout()->addWidget(btn);
}
virtual ~MainWindow() {}
};int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow *w = new MainWindow();
w->showFullScreen();
return app.exec();
}
@Expected output for me when I clicked the button twice is:
true false
true false
but actual output is:
true false
false true
i.e. flag WindowMaximized is dropped and window looks like maximized instead of fullscreen.Qt version is 5.3.1.
-
If you want it full screen, then use showFullScreen() instead of show() in your slot.