Regarding setWindowState(Qt::WindowMaximized) , showMaximized() and width and height getting from QRect are they same?



  • Hi,

    For the generic to get the screen size
    We use

    Widget widgetObject;
    widgetObject.setWindowState(Qt::WindowMaximized);

                          Or
    

    Widget widgetObject;
    widgetObject.showMaximized();

                          Or
    

    QRect rect = qApp->primaryScreen()->geometry();
    int width = rect.width();
    int height = rect.height();
    Widget widgetObject;
    widgetObject.setFixedSize(width,height);

    Are these three usage one at the same or any much difference?.

    Thanks


  • Moderators

    @Pradeep-Kumar
    (1) and (2) should result in the same. Although for (1) you should use the following instead widget->setWindowState(widget->windowState() | Qt::WindowMaximized);

    (3) is definitly different since there you only set the size but not the state of the window. But i guess it depends on the platforms window system if the appearance is different. But there is a reason for a window state being available.



  • k then what is the difference between state and width and height of QRect of screen taken?.

    Thanks,


  • Moderators

    @Pradeep-Kumar
    the state itself. In MS Windows for example watch the different window buttons between the normal and maximized states. Also note that a maximized window doesnt have a border where the just resized one does.
    Different states may result in different available actions, etc


Log in to reply