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().

                    else{
                        warningDialog.minimumSizeHint();
                        warningDialog.open();
                    }


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



  • @ else{
    warningDialog.minimumSizeHint();
    warningDialog.open();
    }
    @

    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.

    @
    MessageDialog{
    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: {
            if(app.savedAsBool){
                app.saved = true;
                masterResource.saveTranslation(saveAsFile.saveFileName);
                Qt.quit();
            }
            else if(app.madeList && !app.savedAsBool)
            {
                app.quitBool = true;
                app.saveAs();
            }
            else{
                noListDialog.open();
            }
        }
    
        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.