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. Dialog shouldn't be closed automatically when OK is pressed
Forum Updated to NodeBB v4.3 + New Features

Dialog shouldn't be closed automatically when OK is pressed

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 972 Views 2 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.
  • C Offline
    C Offline
    CompuChino
    wrote on last edited by CompuChino
    #1

    Hello,

    my dialog accepts input in 2 TextFields. When the user presses OK, I check if the input in the TextFields is equal. If not the dialog shouldn't be closed. How can I do this?

    import QtQuick 2.3
    import QtQuick.Controls 1.3
    import QtQuick.Dialogs 1.2

    Dialog {
    id: dialogVirtualKeyboard
    standardButtons: StandardButton.Ok | StandardButton.Cancel

    MessageDialog {
        id: passwordMessage
        text: "Passwords must be equal!"
    
        onAccepted: dialogVirtualKeyboard.open()
    }
    
    onAccepted: {
        if (inputText.text != inputTextRepeat.text)
            passwordMessage.open()
    }
    
    TextField {
        id: inputText
        height: 25; width: parent.width
    }
    
    TextField {
        id: inputTextRepeat
        height: 25; width: parent.width
    }
    

    }

    Any help is highly appreciated!

    Christine

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

      Have you tried calling open() from onAccepted? I don't know if that will work.

      It doesn't seem like a very friendly UI: the user clicks ok, and then nothing happens? How do they know what's wrong? You could open another dialog telling them what's wrong, and from that dialog, re-open the first dialog.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CompuChino
        wrote on last edited by
        #3

        I just changed my source code according to your suggestion. When the texts are not equal I open a MessageDialog in onAccepted (but the original dialog is already closed) and when this is closed I open the original dialog again. But that's not what I want.

        The original dialog should stay open when the MessageDialog is shown. I can't believe that this isn't possible.

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

          Did you try calling open() in onAccepted?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CompuChino
            wrote on last edited by
            #5

            Yes I did. But I also have to open my MessageBox in onAccepted and then input is allowed in both dialogs at the same time.

            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