Good evening,

I am using QT5.7.1, and the UI is defined using QML. Our application is used to control an instrument and is running in kiosk mode.

I am trying to use MessageDialog element to notify the operator when certain situations arise, such as low battery power, low disk space, ...

The MessageDialog is declared in my main.qml, and is opened when a signal (notifyOperator) is emitted by a c++ method.

I have defined a slot/function in main.qml (onNotifyOperator) to handle the signal. The two are connected in the main() function of my application (similar to the example in I tried to used QML Connections element to connect the signal and slots with the following compilation error: Invalid attached object assignment. I still don't understand this one, but I want to resolve this at a later date.

I also came across a comment stating that it is absolutely mandatory to do property changes before opening the Dialog, i.e. in a closed state. If I want to change things in a MessageDialog already opened, I have to close it, change the properties and then open it again. It is not sufficient to change properties and then to close and reopen (like a "redraw"). This is what the onNotifyOperator(), open the MessageDialog() after the properties are changed.
More troubling, is the fact that I am not changing the properties for the MessageDialog and still get an incomplete display of the element.

The file main.qml contains the following declaration:

Qt Code:
  1. QtObject {
  2. property real defaultSpacing: 10
  3. property SystemPalette palette: SystemPalette { }
  5. //
  6. // scale factors dynamically computed
  7. //
  8. property double horizScaleFactor : Screen.width / 1280.0;
  9. property double vertScaleFactor : Screen.height / 800.0;
  11. property var splashWindow: Splash {
  12. onTimeout:
  13. {
  14. console.log( "Splash timeout: ...)
  16. ...
  17. controlWindow.visible = true
  18. }
  19. }
  21. property var controlWindow: Window {
  22. id: mainWindow
  23. objectName: "mainWindow" // Needed for signal/slot connection
  25. // Form
  26. // this function is our QML slot; used to open a MessageDialog to notify the operator
  27. function notifyOperator()
  28. {
  29. console.log( "notifyOperator slot")
  31. }
  32. ...
  33. }
To copy to clipboard, switch view to plain text mode 
The MessageDialog is declared as follow (part of controlWindow):

Qt Code:
  1. MessageDialog {
  2. id: myMessageDialog
  4. modality: Qt.WindowModal
  5. icon : StandardIcon.Warning
  6. standardButtons: StandardButton.Ok
  8. title: qsTr( "Power Adapter Status")
  9. text: qsTr( "Please disconnect the power adapter")
  11. onAccepted: {
  12. console.log( "messageDialog accepted() ")
  13. }
  15. Component.onCompleted: {
  16. console.log( "messageDialog.Component.onCompleted(); visible: ", visible)
  17. console.log( "messageDialog.Component.onCompleted(); title: ", title)
  18. console.log( "messageDialog.Component.onCompleted(); text: ", text)
  19. }
  20. onVisibilityChanged: {
  21. console.log( "messageDialog.onVisibilityChanged(); visible: ", visible)
  22. console.log( "messageDialog.onVisibilityChanged(); title: ", title)
  23. console.log( "messageDialog.onVisibilityChanged(); text: ", text)
  24. }
  25. }
To copy to clipboard, switch view to plain text mode 
The messages displayed in the Application Output tab include:

Qt Code:
  1. Starting U:\gitMaster\ ...
  3. qml: messageDialog.Component.onCompleted(); visible: false
  4. qml: messageDialog.Component.onCompleted(); title: Power Adapter Status
  5. qml: messageDialog.Component.onCompleted(); text: Please disconnect the power adapter
  7. ...
  8. qml: notifyOperator slot
  9. qml: messageDialog.onVisibilityChanged(); visible: true
  10. qml: messageDialog.onVisibilityChanged(); title: Power Adapter Status
  11. qml: messageDialog.onVisibilityChanged(); text: Please disconnect the power adapter
  12. The program has unexpectedly finished.
To copy to clipboard, switch view to plain text mode 

Finally, I have attached a screen capture of the MessageDialog


As I pointed out, the MessageDialog is incorrect even if the title and text elements are fixed. Any suggestions?
Also, how to get rid of the question mark in the title bar?