Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Custom QtQuick MessageDialog
Forum Updated to NodeBB v4.3 + New Features

[Solved] Custom QtQuick MessageDialog

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 6.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.
  • K Offline
    K Offline
    krisjobs
    wrote on last edited by
    #1

    Greetings,

    I have a simple question: is there a way to make a custom MessageDialog in QtQuick?

    The actual problem I seem to have is that when the property standardButtons gets more than one value (for example StandardButton.Abort | StandardButton.Retry at the same time) I get the error setGeometry: Attempt to set a size (...) violating the constraints (...) on window QQuickWindow/''. (which I assume is a not yet fixed bug, as far as I could find)

    And besides, I'd like to tweak the visuals a little bit.

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      I think the fastest way is to just make your own dialog from scratch, with QML that should be very easy?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        krisjobs
        wrote on last edited by
        #3

        That's true, that crossed my mind, but a MessageDialog has some properties I am not sure I can implement: such as Modality and the fact that the Dialog is a complete separate window, that can be maximized, minimized and closed with the X button

        1 Reply Last reply
        0
        • X Offline
          X Offline
          Xander84
          wrote on last edited by
          #4

          I don't know but but on mobile devices like android and iOS you cannot have multiple windows anyway, so you just have to use an overlay in QML.

          Does the default MessageDialog work on mobile devices? I've tried the FileDialog that works kinda, but looks and works terrible on android xD

          IF you try to open an actual second window the app will crash in most cases.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            krisjobs
            wrote on last edited by
            #5

            So what would be a possible workaround to a FileDialog?

            1 Reply Last reply
            0
            • X Offline
              X Offline
              Xander84
              wrote on last edited by
              #6

              I mean the FileDialog works don't get me wrong, but the name filter's are not working (at least with the QML dialog) and it doesn't look that good in my opinion, you have to see it yourself. On a desktop computer it uses the native file dialog as far as I know, so no problems there.

              I guess it depends what you want to do and if you also want to target mobile platforms you can't use multiple windows anyways.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                krisjobs
                wrote on last edited by
                #7

                OK, I think I have found a possible solution to my Problem:

                @import QtQuick.Window 2.0
                ApplicationWindow {

                    // some stuff
                
                    Window {
                            visible: true
                            modality: Qt.ApplicationModal
                            width: 600
                            height: 400
                
                            //implement buttons and logic
                      }@
                

                }

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  claudiub
                  wrote on last edited by
                  #8

                  Your solution is not a solution but a workaround. The original bug is serious. It practically makes the MessageDialog from QtQuick unusable.

                  I get the very same error you reported with "violating the constraints (…) on window QQuickWindow". The dialog is "freezing" and I did not find a solution for it. I want to take benefit of standardButtons feature, I only need Yes/No confirmation and I cannot use MessageDialog.

                  I don't care about layout/fonts etc, is there an alternative for a simple Yes/No confirmation dialog in QtQuick?

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    claudiub
                    wrote on last edited by
                    #9

                    few minutes after my previous post, I got a solution/workaround for it.
                    It doesn't work if you define the standardButtons inside the MessageDialog like:

                    @ MessageDialog {
                    id: messageDialogOnRemove
                    modality: Qt.WindowModal
                    // ... other stuff here..
                    standardButtons: StandardButton.Yes | StandardButton.No
                    }@

                    but it works if you avoid defining the standardButtons in the declaration above and put it just before you want to display it, like:

                    @messageDialogOnRemove.standardButtons = StandardButton.Yes | StandardButton.No
                    messageDialogOnRemove.show()@

                    Hope this helps someone.

                    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