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

Imperatively setting TextEdit's alignment results in incorrectly aligned text

    XMLWordPrintable

Details

    • e7d0395b4 (dev), d7453add3 (6.7), dd60632f8 (tqtc/lts-6.5)

    Description

      In the example below, the text's alignment should change to the right:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          id: root
      
          TextEdit {
              id: textEdit
      
              property string t: qsTr("<b>Enter</b> some text...")
      
              text: t
      //        placeholderText: t
              onImplicitWidthChanged: print("implicitWidth", implicitWidth)
              textFormat: TextEdit.AutoText
      //        horizontalAlignment: TextEdit.AlignRight
              width: 200
              height: 200
              Rectangle {
                  anchors.fill: parent
                  color: "transparent"
                  border.width: 1
                  opacity: 0.5
              }
          }
      
          Timer {
              running: true
              interval: 800
              onTriggered: {
                  textEdit.horizontalAlignment = TextEdit.AlignRight
              }
          }
      }
      

      If you click in the TextEdit, the mouse cursor will be aligned to the right, however. The text will become right-aligned when you start typing.

      Works with 5.7, broken in 5.8.

      Setting the alignment declaratively works as expected.

      Attachments

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

        Activity

          People

            edcooke Ed Cooke
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change