Results 1 to 5 of 5

Thread: How animate a message that appears on bottom?

  1. #1
    Join Date
    Nov 2014
    Posts
    33
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Question How animate a message that appears on bottom?

    I'm showing a message on the bottom:

    Msg.qml
    Qt Code:
    1. import QtQuick 2.4
    2.  
    3. Item {
    4. property alias text: mf.text
    5. anchors.fill: parent
    6. antialiasing: false
    7. opacity: 0.9
    8. z: 100
    9.  
    10. MsgForm {
    11. id: mf
    12. width: parent.width
    13. y: parent.height - height - 5
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    MsgForm.ui.qml
    Qt Code:
    1. import QtQuick 2.4
    2.  
    3. Item {
    4. property alias text: msg.text
    5.  
    6. width: 200
    7.  
    8. id: message
    9. height: msg.height+10
    10.  
    11. Rectangle {
    12. id: rectangle
    13. color: "#fb9191"
    14. anchors.fill: parent
    15. border.color: "#fd6666"
    16. border.width: 2
    17.  
    18. Text {
    19. id: msg
    20. anchors.top: parent.top
    21. anchors.topMargin: 2
    22. textFormat: Text.PlainText
    23. anchors.right: parent.right
    24. anchors.rightMargin: 4
    25. anchors.left: parent.left
    26. anchors.leftMargin: 4
    27. wrapMode: Text.WordWrap
    28. clip: false
    29. font.bold: true
    30. font.pointSize: 12
    31. font.family: "Tahoma"
    32. }
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 

    How can animate the form to appears from bottom smoothly?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How animate a message that appears on bottom?

    Quote Originally Posted by lqsa View Post
    How can animate the form to appears from bottom smoothly?
    I am afraid I don't understand what you mean with "appear from bottom".
    Can you describe the visual effect you want to achieve?

    Cheers,
    _

  3. #3
    Join Date
    Nov 2014
    Posts
    33
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How animate a message that appears on bottom?

    Please, see these images:

    - Step 1:

    ...
    -Step n:

    ...
    -Final step:


    I hope it serves as an example.

    Cheers.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How animate a message that appears on bottom?

    Well, that depends on how you position the element, e.g whether you are using anchors or y-values for vertical positioning.

    In both cases you probably want a local numerical property that you animate and then use that property to bind to either an anchor margin or the y property expression.

    If I assume that MsgForm is the element, then it is the latter. Instead of the (- height - 5) part you use the new property, which you start at 0 and then animate to (-height - 5)

    Cheers,
    _

  5. #5
    Join Date
    Nov 2014
    Posts
    33
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How animate a message that appears on bottom?

    It works!

    Qt Code:
    1. MsgForm {
    2. property bool showing: false
    3. property int position: showing ? height : 0
    4. width: parent.width
    5. y: parent.height - position
    6. Behavior on position {
    7. NumberAnimation {duration: 500}
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Only changing the showing property to show or hide.

    Thank you very much!!

Similar Threads

  1. Animate drawing
    By ogh in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2011, 19:35
  2. error message appears when function is called
    By babygal in forum Qt Programming
    Replies: 11
    Last Post: 14th June 2010, 23:49
  3. Animate in Dialog
    By wirasto in forum Newbie
    Replies: 1
    Last Post: 11th December 2009, 11:34
  4. Replies: 7
    Last Post: 15th November 2007, 17:19
  5. animate a window
    By iGoo in forum Qt Programming
    Replies: 4
    Last Post: 27th June 2006, 10:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.