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

anchor warning on removal of Tabbutton from a tabBar

XMLWordPrintable

      If a tabbutton is anchored wrt its parent (tabBar), it gives a warning when removed from tab.

      TabBar {
              id: tabBar
              width: 500
              height: 44
              anchors.top: parent.top
              background: Rectangle {
                  color: "gray"
              }
      
              TabButton {
                  id: defaultTab
                  width: 120
                  height: tabBar.height 
                  anchors.top: parent.top  // If user comments this, tabbutton will not be positioned correctly.
                  /** background rectangle for default tab */
                  background: Rectangle {
                      id: tabBackground
                      border.color: (defaultTab.activeFocus ||
                                     defaultTab.hovered) ?
                                        "blue" : "red"
                      border.width: 1
                      color: "yellow"
                  }
              }
          }
          Button {
              id: button
              width: 50
              height: 50
              text: "close"
              anchors.centerIn:parent
              onClicked:{
                  tabBar.removeItem(tabBar.itemAt(tabBar.currentIndex));
              }
          }
      

      Warning is generated for anchors.top: parent.top:

      TypeError: Cannot read property 'top' of null 
      

      As a workaround user can set implicitHeight and comment the anchor settings, which will prevent the warning and will position the tabbutton correctly.
      But there should not be such warning.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            shmittal Shveta Mittal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes