Is MessageDialog broken in Qt 6.5?
-
I'm trying to use a MessageDialog in response to the user clicking a button e.g. User clicks Export button and a message dialog is presented telling the user that the operation has been completed.
This works the first time you open the dialog but all subsequent open() calls don't open the dialog. What's stranger is that if the dialog is instantiated in an item that got pushed onto a StackView, popping that item off the stack and pushing it back onto the stack sort of clears it out and it works again but only once. If the dialog is instantiated in the application's main Window, it only works once and nothing will make it reappear.
Going deeper, I never see onAccepted code getting executed. If I have a console.log output in onVisibilityChanged, I only see that executed once when the dialog opens.
It's as though the dialog got deleted somehow. Anyone have any ideas?
-
Okay, after reading through the source code for qquickmessagedialog.cpp, I saw a use-case for supporting different buttons. I added the following:
onButtonClicked: function (button, role) { switch (button) { case MessageDialog.Ok: exportDialog.close() break; } }Apparently, without this and explicitly telling the dialog to close, you can't reopen the message dialog. Seems goofy to me.