Important: Please read the Qt Code of Conduct -

Getting correct geometry size after setMinimumSize() and showMaximized()?

  • Hi,
    After I set my main window's minimum size, and then manually maximize it, I am trying to retrieve the new dimensions, but it seems to be just returning the dimensions of whatever I call setMinimumSize() with.
    Here is my code:

    MainWindow::MainWindow(QWidget *parent) :

    qDebug("Dimensions %d, %d", size().width(), size().height());


    The output is:
    "Dimensions 920, 500"

    Any ideas how I get the REAL geometry or frame size for the main window, after I move or resize or maximize or manipulate it in any way?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are asking for the geometry too early.

    showMaximized doesn't happen right now in the constructor, Qt's eventLoop need to start first. You can get the information e.g. in the resizeEvent

    Hope it helps

  • Thank you very much SGaist.

  • Lifetime Qt Champion

    You're welcome !

    If this answers your question, then please update the thread title prepending [solved] so other forum users may know a solution has been found :)

Log in to reply