Dialog title at runtime



  • Hi

    I'm using QML dialog of:

    import QtQuick.Dialogs 1.2
    
    Dialog {
      id: someDialog
      title: "initial title"
    }
    

    I can set its title (on title bar) when it is created but at run time, from JS, like:

        onSomething: someDialog.title = "changed title"
    

    it doesn't set title again (even if slot onSomething is invoked properly)
    Did I miss something?



  • Hi! The following works for me.

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    import QtQuick.Dialogs 1.2
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Dialog {
            id: someDialog
            title: "initial title"
        }
    
        Row {
    
            Button {
                text: "click me"
                onClicked: someDialog.title = "changed title"
            }
    
            Button {
                text: "toggle"
                onClicked: someDialog.visible = !someDialog.visible
            }
    
        }
    }
    


  • It changes title but only when dialog is closed and opened again, so following:

      onSomething: {
          someDialog.title = "changed title"
          someDialog.close()
          someDialog.open()
      }
    

    works somehow, but I daresay it is not elegant solution and dialog window blinks.

    But maybe I'm demanding something unusual or obsolete.
    I just wanted to add "not saved" to settings dialog when anything was changed.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.