Best way to get values ​​from the QML Modal dialog

In my QT C ++ application, I call the QML ModalDialog with 2 buttons (OK / CANCEL) that appear correctly on the screen, and therefore there is no problem.

However, I am struggling to find a way to get the QT C ++ application on which the button was clicked.

I can’t somehow “freeze” when I call QML ModalDialog, wait there until the user clicks the “OK” button or the “Cancel” button. I see that the application calls QML ModalDialog and immediately exits this part and continues.

QMetaObject :: invokeMethod can call the QML function and have a return value, but it just does not wait until the user presses one of the buttons, it just exits immediately, so there is no need to use it.

I want to use this QML ModalDialog in several places of my application (the QML modal dialog may have different text passed from my QT C ++ application), so I was looking for a general solution for this.

In general, I'm looking for something like this:

C / C ++ return_value = QML_Modal_Dialog (....)

Can someone point me in the right direction? Thanks

+3
source share
2 answers

The QML modal dialog comes with two received signals and is canceled. If you provide handlers for these two signals in your code, you can find out which button is pressed. You can refer to the reference guide below.

Modal Dialog Ref 1

Modal Dialog Ref 2

Hope this helps!

+1
source

, , , - .

Dialogs QML. -, QML - , . Purnima ( Qt 5.6 ). .

, a() , (, onAccepted onRejected) . , .

0

All Articles