[SOLVED] Why am I getting QWindowsWindow::setGeometry: Unable to set geometry warning with Qt 5.12.0


I migrated some code from Qt 5.6.0 to 5.12.0. Suprisingly, I’m getting lots of warnings related to QWindowsWindow::setGeometry. Whenever a dialog is shown on top of another, I get this warning.

I could isolate the problem in a MCVE, it’s very simple and minimal, all parenting look good, however, we get the warning when button is pressed:

QWindowsWindow::setGeometry: Unable to set geometry 132x30+682+303 on QWidgetWindow/'QDialogClassWindow'. Resulting geometry:  132x42+682+303 (frame: 4, 28, 4, 4, custom margin: 0, 0, 0, 0, minimum size: 116x42, maximum size: 16777215x16777215).


#include <QApplication>
#include "mainframe.h"
#include <qDebug>

void MessageOutput( QtMsgType type, const QMessageLogContext &context, const QString &msg)
    qDebug() << msg;

int main( int argc, char* argv[] )
    QApplication app(argc, argv);


    MainFrame wnd;

    return app.exec();


#include <QMainWindow>

class QPushButton;
class MainFrame : public QMainWindow


public slots:
    void showPopup();

    QPushButton* button;


#include "mainframe.h"

#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>

    QWidget* widget = new QWidget( this );
    widget->setLayout( new QVBoxLayout( widget ) );

    QPushButton* pTextButton = new QPushButton( "Show popup", widget );
    widget->layout()->addWidget( pTextButton );
    connect( pTextButton, SIGNAL(clicked()), this, SLOT(showPopup()) );

    setCentralWidget( widget );

void MainFrame::showPopup()
    QDialog dlg( this );
    dlg.setLayout( new QVBoxLayout() );
    dlg.layout()->addWidget( new QLabel("popup message",&dlg) );

I see the issue under Windows 7 and 10. Am I doing anything wrong?

I know the warning can be removed by setting setMinimumSize (see https://stackoverflow.com/a/31231069/3336423), but why should we do this for every widget we create? Is there a way to fix that for good?


The issue was reported to Qt:

To the code in OP is OK, it’s just a Qt bug.

It’s marked as "P2 Important", so hopefully it should be fixed in a next release.

Update: It’s still not fixed in Qt 6.2.2…

Answered By – jpo38

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *