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. Using Timer in a ListView
QtWS25 Last Chance

Using Timer in a ListView

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 5.1k 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.
  • J Offline
    J Offline
    jech
    wrote on last edited by
    #1

    Hello,

    I 'm trying to create a ListView with following behavior: If I click an Item it will vertically expand but after some time it will collapse back to it's original size. I suppose I need to create a timer which will change the state of the expanded delegate back to default.

    Unfortunately the documentation for Timer didn't help me much.

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xsacha
      wrote on last edited by
      #2

      I hope this helps:

      @import QtQuick 1.0

      Rectangle {
      property int time: 800
      property int size: 300
      width: size; height: size; radius: size
      color: "red"
      Behavior on radius { NumberAnimation { duration: time } }
      Timer {
      id: reset
      interval: time;
      onTriggered: parent.radius = size
      }

      MouseArea {
          anchors.fill: parent
          onClicked: {
              parent.radius = 0;
              reset.start()
          }
      }
      

      }@

      Just hacked it up. It starts with a circle. Click it and it turns in to a rectangle and after becoming a rectangle, it will turn in to a circle again (with a Timer).

      • Sacha
      1 Reply Last reply
      0
      • K Offline
        K Offline
        kamalakshantv
        wrote on last edited by
        #3

        [quote author="xsacha" date="1291284121"]I hope this helps:

        @import QtQuick 1.0

        Rectangle {
        property int time: 800
        property int size: 300
        width: size; height: size; radius: size
        color: "red"
        Behavior on radius { NumberAnimation { duration: time } }
        Timer {
        id: reset
        interval: time;
        onTriggered: parent.radius = size
        }

        MouseArea {
            anchors.fill: parent
            onClicked: {
                parent.radius = 0;
                reset.start()
            }
        }
        

        }@

        Just hacked it up. It starts with a circle. Click it and it turns in to a rectangle and after becoming a rectangle, it will turn in to a circle again (with a Timer).[/quote]

        Thanks for the sample eg.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jech
          wrote on last edited by
          #4

          xsacha> Sorry for my late reply. The example is perfect it is exactly what I needed. Thank you!

          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