MessageDialog setGeometry error. Need help.

  • Im trying to display a warning dialog when the user of the program tries to quit without having saved their latest editing. When the message dialog displays i get this warning in the console window: setGeometry: Attempt to set a size (354x87) violating the constraints(354x149 - 16777215x16777215) on window QQuickWindow/''.

    I tried using width and height, and setWidth and setHeight but it wont work. I guess the setGeometry happens automatically when I open the window?

    Do anyone know how to fix this problem?

  • You might want to set the sizehints minimum size. I appears you're trying to create a dialog that is too small, but you already figured it out.
    The sizeHint tells how big the dialog may be when space is available.

  • I cant really get it to work. Like how do you use it?

    This is my current code, which gives an error because minimumSizeHint() isnt a function for the message dialog, neither is sizeHint().


  • well, the code is not displayed like that, but yeah, you get the idea.

  • @ else{

    There you go.

  • Hmm, Sorry, that was QWidget function. That should not work indeed.
    Did you create the dialog as a child of the mainwindow? By default the dialog should take a proper shape when it's a child.
    Maybe show a bit more code, so we are able to fix it.

  • Yes, the dialog is a child of the main window.
    This is the code for the dialog.

    id: warningDialog;
    icon: StandardIcon.Warning;

        title: qsTr("Warning!");
        text: qsTr("You have not saved your last translations.");
        standardButtons: StandardButton.Cancel | StandardButton.Discard |  StandardButton.Save;
        onAccepted: {
                app.saved = true;
            else if(app.madeList && !app.savedAsBool)
                app.quitBool = true;
        onDiscard: Qt.quit();
        onRejected: console.log("Canceled");


Log in to reply

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