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

Add border.type property to QML2's Rectangle to specify border behavior/placement (inner, outer, aligned, odd-shifted-0.5-pixel)

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None
    • None

      QML1's border behavior of shifting the border 0.5 pixels for odd-size borders is a bit unintuitive and results in ugly workarounds such as:

      Rectangle {
          id: intuitiveRect
          width: 8; height: 8
          border.color: "gray"
      
          Rectangle {
              id: centeredRectangle
              anchors {
                  fill: parent
                  margins: 2
              }
          }
      }
      
      Rectangle {
          id: outerBorderWorkaround
          width: 9; height: 9
          border.color: "gray"
      
          Rectangle {
              id: centeredRectangle
              anchors {
                  fill: parent
                  leftMargin: 3; topMargin: 3
                  rightMargin: 2; bottomMargin: 2
              }
          }
      }
      
      Rectangle {
          id: innerBorderWorkaround
          width: 7; height: 7
          border.color: "gray"
      
          Rectangle {
              id: centeredRectangle
              anchors {
                  fill: parent
                  leftMargin: 3; topMargin: 3
                  rightMargin: 2; bottomMargin: 2
              }
          }
      }
      

      QML2 adds an alignment property that rectifies this somewhat, but an even better solution would be to represent the behavior with a type-property, where the user can also choose an explicit inner or outer border. For QML2 this is easy to implement, and has low technical risk.

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

            Unassigned Unassigned
            vestbo Tor Arne Vestbø
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes