Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74350

QML Dialog: title cannot be set dynamically

XMLWordPrintable

    • Windows
    • 1edf84eff083eb5412b4c5c7cd3bd8166f15f61f (qt/qtquickcontrols/5.12)

      For Dialog (QtQuick.Dialogs 1.3) title, user is able to set it dynamically. whereas Label text can be set easily.

      In Below code, Title for Dialog is not getting set when a function is used.

      Dialog {
          function newTitle(){
                  return "new text";
              }
          id: textDialog
          visible: true
          title: newTitle() // Does not work
      // title : "title123" //This works fine
          onAccepted: {console.log(title)}
          width:500
          contentItem.width: 500;
          contentItem.implicitWidth: 500;
              Label {
                  text: newTitle()
                  anchors.fill: parent
                  wrapMode: Text.WrapAtWordBoundaryOrAnywhere
              }
      }
      
      

      Refer to the attached sample code. You can see that title for dialog does not get set to return value of newTitle()

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            andysh Andy Shaw
            shmittal Shveta Mittal
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes