Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

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

    QML and Qt Quick
    2
    3
    1800
    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
      sandeepsastry last edited by

      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 Reply Quote 0
      • p3c0
        p3c0 Moderators last edited by

        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 Reply Quote 0
        • S
          sandeepsastry last edited by

          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 Reply Quote 0
          • First post
            Last post