Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to implement TextInput drag and drop

How to implement TextInput drag and drop

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmltextedit
2 Posts 2 Posters 620 Views
  • 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.
  • Y Offline
    Y Offline
    Yujeonja
    wrote on last edited by
    #1

    I am making a simple text editor using QML. I want to make feature that select text by mouse and drag to move the text(Like the modern text editors working).
    But there seems no properties or methods for the selected area rectangle.

    TextInput {
      id: textInput
      width: 100
      height: 50
      selectByMouse: true
    }
    

    This code can make select text by mouse but when I try drag this, the previous selection is removed and new selection is started.
    My idea was using MouseArea, but I can't calculate the position of the selected text area rectangle.
    How can I do this? Is it imposible?

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      You are trying to do 2 things that require the same actions. Drag and drop is not built into the TextInput object. So you need to learn how drag and drop works.

      Next, since you need to be able to change the mode of your TextInput you need to control when a selection can occur. Say for instance if text is selected that you do NOT want selection motion to work. Then use the selectedText property to control the selectByMouse property:

      selectByMouse: selectedText <= 0
      

      I do not know if this will lock you into that mode. So you may need a way to back out of a selection. What happens when you click the text again? Does it deselect the text?

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved