How To Get The Full Width Of A Maxamized Window

  • Hello, I have the following code that should return something similar to 1920 but instead it gives me 1117.

    Can anyone please tell me why?

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    int iWidth1 = this->geometry().width(); 
    int iWidth2 = this->size().width();


    Both Width1 and Width2 return the same value

    Thanks in advance


    After looking I see that the default window size is 1117 which means that even though I am calling fullscreen and then getting the window width, it is not getting the new width since 1117 is the old width.
    How can I force it to get the new/current width?

  • Moderators


    AFAIK, you won't get it in the constructor. Either call a function from other than constructor and fetch the size. Or other way would be to call this from constructor:

    where getSizeMainWindow() contains code to get the size.

  • Lifetime Qt Champion


    The single shot can be 0, IIRC it should get call once the constructor is ended

Log in to reply

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