Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved How to get coordinate of the TextArea current selection text?

    QML and Qt Quick
    1
    1
    39
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      senmx last edited by senmx

      ScrollView {
          id: scroll
          width: parent.width
          height: parent.height
          contentWidth:  width
          contentHeight: col.height
          Column {
              id: col
              width: parent.width
              anchors.fill: parent
              TextArea {
                  id: text
                  readOnly: true
                  width: parent.width
                  textFormat: Text.RichText
                  selectByMouse: true
              }
          }
          Component.onCompleted: {
              let i = 100;
              text.cursorPosition = i;
              text.moveCursorSelection(i+10, TextEdit.SelectCharacters);
              //How to get the Y corrdinate of the current selection text? Then I would like scroll to the corresponding position.
              let y = 0;
          }
      }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post