Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MessageDialog setGeometry error. Need help.
Qt 6.11 is out! See what's new in the release blog

MessageDialog setGeometry error. Need help.

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    skammers
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        skammers
        wrote on last edited by
        #3

        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();
                        }
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          skammers
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            skammers
            wrote on last edited by
            #5

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

            There you go.

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              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.

              Greetz, Jeroen

              1 Reply Last reply
              0
              • S Offline
                S Offline
                skammers
                wrote on last edited by
                #7

                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");
                

                @

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved