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
    explicit MainWindow(QWidget *parent = 0) : QMainWindow(parent) {
    QPushButton *btn = new QPushButton("hideshow");
    connect(btn, &QPushButton::clicked, = {
    qDebug() << isFullScreen() << isMaximized();
    virtual ~MainWindow() {}

    int main(int argc, char *argv[])
    QApplication app(argc, argv);
    MainWindow *w = new MainWindow();
    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.

  • Moderators

    If you want it full screen, then use showFullScreen() instead of show() in your slot.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.