Nominate our 2022 Qt Champions!

QML MessageBox onYes called two times after click

  • When I run project on PC any other than mine, onYes function from MessageBox executes twice. I have only made some text changes to the DefaultMessageBox.qml but even when I copied it from my PC the issue persists. I can't recall any other changes that I could have made to the Qt files, yet it must be somewhere there. I execute project on both iOS and Mac desktop with the same result. I've checked if there is only one MessageBox or Button, also the onClick from the DefaultMessageBox is called only once. Please help


  • Qt Champions 2017

    It should not be like that. I have used on MAC and android. It is called handler only once. Can you paste your sample code here ? Here is what I have tried.

    @ MessageDialog {
    title: "Overwrite?"
    icon: StandardIcon.Question
    text: "file.txt already exists. Replace?"
    standardButtons: StandardButton.Yes | StandardButton.YesToAll |
    StandardButton.No | StandardButton.NoToAll | StandardButton.Abort
    Component.onCompleted: visible = true
    onYes: console.log("Cal me - yes")
    onNo: console.log("Call me - NO")
    onRejected: console.log("aborted")

  • @ MessageDialog {
    id: messageDialog
    text: "Czy chcesz pobrać ten wiersz?"
    onYes: {
    console.log("MessageDialog onYes")
    standardButtons: StandardButton.Yes | StandardButton.No
    Component.onCompleted: visible = false

    and this gives me such log
    @DefaultMessageBox onClicked
    MessageDialog onYes
    MessageDialog onYes@

    I added debug message in the DefaultMessageDialog.qml to be sure that there is only one MessageDialog and only one Button.

    As I said before, the dialog works correct on my Mac that I started the project, but whenever I clone repo to any other computer the issue exists. I tried to update Qt, Qt Creator but with no effect.

Log in to reply