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. [SOLVED] QML - Dynamically swap the visibility/opacity between overlapping Text and TextArea
QtWS25 Last Chance

[SOLVED] QML - Dynamically swap the visibility/opacity between overlapping Text and TextArea

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k 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.
  • S Offline
    S Offline
    sandeepsastry
    wrote on last edited by
    #1

    I want to have a widget in QML which has combination of the following behaviors:

    1. Multi line edit
    2. Auto scroll the content as and when I hit newline. (The content on top of the page keeps going up as and when I enter new content at the bottom)
    3. Have a placeholder text functionality.

    As far as I know, only Text and TextField are having placeholder text property and only TextArea is having a multi line edit plus auto scroll. But If there is any such widget with all the combinations then, my question "Dynamically swap the visibility/opacity between overlapping Text and TextArea " would be invalid.

    In case there is no such widget (I wonder why), I am thinking to have a rectangle which has both Text and TextArea overlapping and based on the below logic I want to have the visibility/opacity/focus on one of them:

    If the Text Area is empty (0 characters), then have the Text in the foreground with focus and with the placeholder text "Enter some text". But as soon as the user starts typing, the Text should lose the focus, opacity and go to background and the TextArea should gain the focus and come to the foreground and start accepting multi line input. Similarly, when TextArea is in the foreground and is empty (0 characters) and when the user click on any other widget outside my Rectangle, the Text should again gain the focus, come to the foreground and display the placeholder again.

    I tried to get inspiration from this code "here...":http://stackoverflow.com/questions/15558831/simple-textarea-element-in-qml, but failed miserably, it would be helpful if anyone can help me with a few lines of code or give me some pointers on how to solve this.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      If I understood your requirement correctly, it would be easy to add a Text element to TextArea and then animate the opacity of Text element depending upon the conditions.

      157

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sandeepsastry
        wrote on last edited by
        #3

        Thanks for the response. I got a bit lazy to update the post. I found the answer in here "code":http://stackoverflow.com/questions/27088152/qml-dynamically-swap-the-visibility-opacity-between-overlapping-text-and-texta/27088416#comment42684916_27088416

        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