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

TableView header for Qt Quick Controls does not follow horizontalAlignment option.

    XMLWordPrintable

Details

    • 44e9533361045f299f43aa21bac55eaed87316f7

    Description

      The headers in TableView controls does not honor the horizontalAlignment option.

      TableView {
          anchors.fill: parent
          TableViewColumn{ role: "title"; title: "Title"; horizontalAlignment: Text.AlignHCenter; width: 320 }
          TableViewColumn{ role: "author"; title: "Author"; horizontalAlignment: Text.AlignHCenter; width: 320 }
          model: libraryModel
      }
      

      There is a workaround at the moment by modifying the headerDelegate component.

      TableView {
          anchors.fill: parent
          TableViewColumn{ role: "title"; title: "Title"; horizontalAlignment: Text.AlignHCenter; width: 320 }
          TableViewColumn{ role: "author"; title: "Author"; horizontalAlignment: Text.AlignHCenter; width: 320 }
          model: libraryModel
          headerDelegate: Item {
              height: 20
              clip: true
              Rectangle {
                  anchors.fill: parent
                  anchors.leftMargin: -1
                  anchors.topMargin: -1
                  gradient: Gradient {
                      GradientStop { color: "#eee" ; position: 0 }
                      GradientStop { color: "#ccc" ; position: 1 }
                  }
                  border.color: "#aaa"
              }
              Text {
                  anchors.fill: parent
                  horizontalAlignment: Text.AlignHCenter
                  verticalAlignment: Text.AlignVCenter
                  text: styleData.value
                  elide: Text.ElideMiddle
                  renderType: Text.NativeRendering
              }
          }
      }
      

      Attachments

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

        Activity

          People

            bachewii Jens
            leonlee Leonard Lee
            Votes:
            5 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes