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. Calling QML Listview signal handler explicitly from QML
Forum Updated to NodeBB v4.3 + New Features

Calling QML Listview signal handler explicitly from QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 3 Posters 1.7k Views 2 Watching
  • 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
    Yaswanth
    wrote on last edited by
    #1

    I am using Listview(id : listview) in my application. I want to move the listview with up/down arrow buttons as well. So I created up/down buttons with in application to do the movement. When up/down button clicked, I am calling listview.onMovementStarted() and re positioning the listview by changing the contentY. Now the issue is when Listview is moved by flicking on the listview and then arrows are clicked immediately. So firstly onMovementStarted got called and then as listview.onMovementStarted() is called onMovementStarted got called again. Then onmovementEnded() has called though listview is still moving. Can somebody tell how to solve this or it is expected to behave like this?

    Is it proper way to call listview.onMovementStarted() or listview.onMovementEnded() explicitly?

    Thanks in advance for your reply.

    T 1 Reply Last reply
    0
    • Y Yaswanth

      I am using Listview(id : listview) in my application. I want to move the listview with up/down arrow buttons as well. So I created up/down buttons with in application to do the movement. When up/down button clicked, I am calling listview.onMovementStarted() and re positioning the listview by changing the contentY. Now the issue is when Listview is moved by flicking on the listview and then arrows are clicked immediately. So firstly onMovementStarted got called and then as listview.onMovementStarted() is called onMovementStarted got called again. Then onmovementEnded() has called though listview is still moving. Can somebody tell how to solve this or it is expected to behave like this?

      Is it proper way to call listview.onMovementStarted() or listview.onMovementEnded() explicitly?

      Thanks in advance for your reply.

      T Offline
      T Offline
      Tom_H
      wrote on last edited by
      #2

      @Yaswanth
      You don't call another object's signal handler directly. If you want to send it a signal, you invoke the signal as a method, in this case
      listview.movementStarted(). But you don't want to do that either. You can call the flick() method or animate the contentY property.

      If you want to prevent the listview from getting flicked while moving, just check the moving or flicking properties in onMovementStarted() and call cancelFlick().

      Y 1 Reply Last reply
      0
      • T Tom_H

        @Yaswanth
        You don't call another object's signal handler directly. If you want to send it a signal, you invoke the signal as a method, in this case
        listview.movementStarted(). But you don't want to do that either. You can call the flick() method or animate the contentY property.

        If you want to prevent the listview from getting flicked while moving, just check the moving or flicking properties in onMovementStarted() and call cancelFlick().

        Y Offline
        Y Offline
        Yaswanth
        wrote on last edited by Yaswanth
        #3

        @Tom_H Thanks for your reply. Is it recommend way to invoke Signal as a method? Because I didn't find any info in the documentation.

        T 1 Reply Last reply
        0
        • Y Yaswanth

          @Tom_H Thanks for your reply. Is it recommend way to invoke Signal as a method? Because I didn't find any info in the documentation.

          T Offline
          T Offline
          Tom_H
          wrote on last edited by
          #4

          @Yaswanth
          It's in The QML Reference, under QML Object Attributes.

          http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#signal-attributes

          "To emit a signal, invoke it as a method. Any relevant signal handlers will be invoked when the signal is emitted, and handlers can use the defined signal argument names to access the respective arguments."

          Y 1 Reply Last reply
          1
          • T Tom_H

            @Yaswanth
            It's in The QML Reference, under QML Object Attributes.

            http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#signal-attributes

            "To emit a signal, invoke it as a method. Any relevant signal handlers will be invoked when the signal is emitted, and handlers can use the defined signal argument names to access the respective arguments."

            Y Offline
            Y Offline
            Yaswanth
            wrote on last edited by
            #5

            @Tom_H Thanks for your response. I have invoked the Listview signal as a method. But still the problem is same. Signal sequence is as following

            1. listview.onMovementStarted()
            2. listview.onMovementStarted()
            3. listview.onMovementEnded()
            T 1 Reply Last reply
            0
            • Y Yaswanth

              @Tom_H Thanks for your response. I have invoked the Listview signal as a method. But still the problem is same. Signal sequence is as following

              1. listview.onMovementStarted()
              2. listview.onMovementStarted()
              3. listview.onMovementEnded()
              T Offline
              T Offline
              Tom_H
              wrote on last edited by
              #6

              @Yaswanth
              You don't want to invoke the signal. Please read my first reply again.

              Y 1 Reply Last reply
              0
              • T Tom_H

                @Yaswanth
                You don't want to invoke the signal. Please read my first reply again.

                Y Offline
                Y Offline
                Yaswanth
                wrote on last edited by
                #7

                @Tom_H Due to other constraints I can not use flick, so I have to go by signal invoking only.

                GrecKoG T 2 Replies Last reply
                0
                • Y Yaswanth

                  @Tom_H Due to other constraints I can not use flick, so I have to go by signal invoking only.

                  GrecKoG Offline
                  GrecKoG Offline
                  GrecKo
                  Qt Champions 2018
                  wrote on last edited by
                  #8

                  @Yaswanth Why not use a custom function then ? Calling movementStarted makes no sense.

                  1 Reply Last reply
                  0
                  • Y Yaswanth

                    @Tom_H Due to other constraints I can not use flick, so I have to go by signal invoking only.

                    T Offline
                    T Offline
                    Tom_H
                    wrote on last edited by Tom_H
                    #9

                    @Yaswanth
                    You can also prevent unwanted flicking by disabling the buttons when the view is moving.

                    button.enabled:  !listview.moving
                    
                    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