Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
6.2.7, 6.4.1
Description
Steps to reproduce
- Run the code below
- Click "Open Dialog"
- Click on the TextEdit and enter "abc"
- Click "OK" (Important: do this while the TextEdit still has keyboard focus)
import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Window import QtQuick.Controls.Material Window { width: 640 height: 480 visible: true id: root property string testString: "" Button { text: "Open Dialog" anchors.centerIn: parent onClicked: dialogLoader.active = true } Loader { id: dialogLoader active: false sourceComponent: dialogComponent } Component { id: dialogComponent Dialog { id: dialog modal: true parent: Overlay.overlay anchors.centerIn: parent width: parent.width * 0.5 height: parent.height * 0.5 RowLayout { anchors.fill: parent Label { text: "Test:" } TextField { id: textField Layout.fillWidth: true onEditingFinished: { console.log("textField onEditingFinished") root.testString = text } } } standardButtons: Dialog.Ok | Dialog.Cancel onAccepted: { console.log("dialog onAccepted") //testString is not set yet console.log(root.testString) //even when calling Qt.callLater() it isn't set yet Qt.callLater( () => { console.log(root.testString) } ) } onClosed: Qt.callLater( () => { dialogLoader.active = false } ) Component.onCompleted: { dialog.open() /* // WORKAROUND: let applyButton = standardButton( Dialog.Ok ) if( applyButton !== null ) applyButton.focusPolicy = Qt.StrongFocus */ } } } }
Expected output (on Windows and Linux)
qml: textField onEditingFinished qml: dialog onAccepted qml: abc qml: abc
Actual output on macOS, Qt 6.2.7
qml: dialog onAccepted qml: qml: qml: textField onEditingFinished
Actual output on macOS, Qt 6.4.1
qml: dialog onAccepted qml: qml: textField onEditingFinished qml: abc
Workaround
Set focusPolicy = Qt.StrongFocus on the OK button
Notes
We should test Qt 5.15.12 too
Attachments
For Gerrit Dashboard: QTBUG-110295 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
473353,6 | Dialog::done: Prepare exit transition before accepted/rejected signal | dev | qt/qtdeclarative | Status: NEW | -1 | 0 |