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. QML Listview onClick event(solved)
Forum Update on Monday, May 27th 2025

QML Listview onClick event(solved)

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 5.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 27 Mar 2014, 10:05 last edited by
    #1

    Hi all,

    I have used itemAt(mouseX, mouseY) for getting the clicked buttons inside QML listview. It works fine, but when i scroll the listView to bottom and tried to click the bottom or other buttons it is not getting selected. It is taking only the area inside its parent window.
    How can i solve this issue ?

    Ansif

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3685
      wrote on 27 Mar 2014, 10:34 last edited by
      #2

      You need to take into account ListView::originX, ListView::originY, ListView::contentX and ListView::contentY.

      ListView (and Flickable) are only showing a part of the whole content. When you scroll the "move" their content to the right position. So you need to convert the coordinates you get from your MouseArea to the coordinates of the content in the ListView.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        Xander84
        wrote on 27 Mar 2014, 13:43 last edited by
        #3

        there might be a better solution, I don't know exactly what you want to achieve but I guess you just want a click event for all items in the ListView?

        Why don't you use a MouseArea inside the delegate, so every item has its own MouseArea and no need to use itemAt with some "weird" calculations. :p

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on 27 Mar 2014, 14:50 last edited by
          #4

          [quote author="t3685" date="1395916442"]You need to take into account ListView::originX, ListView::originY, ListView::contentX and ListView::contentY.

          ListView (and Flickable) are only showing a part of the whole content. When you scroll the "move" their content to the right position. So you need to convert the coordinates you get from your MouseArea to the coordinates of the content in the ListView.
          [/quote]

          Hi,
          Yes it works, thank you. I have used the contentY property and it is using the exact location.
          Thank you

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on 27 Mar 2014, 14:53 last edited by
            #5

            [quote author="Xander84" date="1395927825"]there might be a better solution, I don't know exactly what you want to achieve but I guess you just want a click event for all items in the ListView?

            Wy don't you use a MouseArea inside the delegate, so every item has its own MouseArea and no need to use itemAt with some "weird" calculations. :p[/quote]

            I never used this behaviour. hence my problem is fixed

            1 Reply Last reply
            0
            • T Offline
              T Offline
              t3685
              wrote on 27 Mar 2014, 19:03 last edited by
              #6

              Don't forget to take into account originX and originY as well.

              1 Reply Last reply
              0
              • X Offline
                X Offline
                Xander84
                wrote on 27 Mar 2014, 19:04 last edited by
                #7

                [quote author="t3685" date="1395946982"]Don't forget to take into account originX and originY as well. [/quote]
                There is no need for that if you use a MouseArea in the delegate or what do you mean!?

                1 Reply Last reply
                0

                5/7

                27 Mar 2014, 14:53

                • Login

                • Login or register to search.
                5 out of 7
                • First post
                  5/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved