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. Impromptu MessageDialog
Qt 6.11 is out! See what's new in the release blog

Impromptu MessageDialog

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 2 Posters 2.2k 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.
  • T Offline
    T Offline
    TonyN
    wrote on last edited by
    #1

    Is there anyway to prompt on-the-fly message box (MessageDialog), and inspect the results, rather than declare a MessageDialog for every message we want to show/ask user?

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

      You can declare one MessageDialog and then change the text/title properties for different messages.

      T 1 Reply Last reply
      0
      • X xargs1

        You can declare one MessageDialog and then change the text/title properties for different messages.

        T Offline
        T Offline
        TonyN
        wrote on last edited by
        #3

        @xargs1 Yes, it's the solution I have to do now for OK button dialog, but if the action after the messagebox depend on what user answer is still depend onAccept() or onYes(), onNo(), then I have to implement its own MessageBox

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

          Add to the MessageDialog:

          property var onYesFunc
          property var onNoFunc
          
          onYes: onYesFunc()
          onNo: onNoFunc()
          

          then you can set onYesFunc/onNoFunc just as you set the text.

          T 3 Replies Last reply
          0
          • X xargs1

            Add to the MessageDialog:

            property var onYesFunc
            property var onNoFunc
            
            onYes: onYesFunc()
            onNo: onNoFunc()
            

            then you can set onYesFunc/onNoFunc just as you set the text.

            T Offline
            T Offline
            TonyN
            wrote on last edited by
            #5

            @xargs1 OK, I will try that. Thanks

            1 Reply Last reply
            0
            • X xargs1

              Add to the MessageDialog:

              property var onYesFunc
              property var onNoFunc
              
              onYes: onYesFunc()
              onNo: onNoFunc()
              

              then you can set onYesFunc/onNoFunc just as you set the text.

              T Offline
              T Offline
              TonyN
              wrote on last edited by
              #6

              @xargs1 It works! Thank you very much

              1 Reply Last reply
              0
              • X xargs1

                Add to the MessageDialog:

                property var onYesFunc
                property var onNoFunc
                
                onYes: onYesFunc()
                onNo: onNoFunc()
                

                then you can set onYesFunc/onNoFunc just as you set the text.

                T Offline
                T Offline
                TonyN
                wrote on last edited by TonyN
                #7

                @xargs1 I am curious wonder how it can work. onYesFunc is a property. How can we call it as a function in the onYes handler?

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

                  http://doc.qt.io/qt-5/qml-var.html

                  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