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. Scrolling the list while mouse is pressed in delegate
QtWS25 Last Chance

Scrolling the list while mouse is pressed in delegate

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

    Hi everyone.

    I need to scroll the list when mouse is pressed and at the bottom or top of the list until mouse is released.
    I tried to use timer, which is scrolling the list while mouse cursor is in position of bottom or top of listView.
    When item of the list is out of screen, all mouse actions of delegate that is out of screen no longer available, and timer doesn't stop when i release the mouse button;
    So, i decided to use mouseArea that is child of listView, but every time i need to get items properties, i have to set currentIndex to ListView, and than use currentItem to get properties.
    It works fine, but i am not sure if it is the best way in such situation.

    I also was trying to make my own mouseArea by reimplementing the QDeclarativeItem, where event will be accepted only when mouse button is released, and when it is pressed event will be ignore.
    But unfurtunaly i failed, because if event->ignore() is set in MousePressEvent(), MouseReleaseEvent() is no longer working.
    Is there any possibility to make that what i want?

    Thanks.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      FranzB
      wrote on last edited by
      #2

      I am not quite sure what you are trying to say, so I hope I do not misunderstand the issue.

      You should not ignore the mouse press event when you need the release event, because the release event will only occur if there was a press event beforehand. You could of course set a flag to prevent execution of code, but I think your problem can be solved otherwise.

      1. Have you already tried to achieve what you want with a Flickable element? If need be, you could build your own element and just parse your click events to the Flickable's movement events.
      2. Another way, pretty fancy, would be to use a simple rectangle that changes its position based on the clicks, i.e. you could implement the scrolling feature by hand.

      Concerning the ListView index issue, I think there is no better solution. I have also had my fights with it, so if there really is a better way, I would also like to know it.

      Hope that was of any help to you.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I'm not sure if I understood what you want to achieve. But I guess it could be the behaviour of the "QAbstractItemView autoScroll property":http://doc.qt.nokia.com/4.7/qabstractitemview.html#autoScroll-prop.

        http://www.catb.org/~esr/faqs/smart-questions.html

        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