Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scrolling through the QListView items !
Forum Updated to NodeBB v4.3 + New Features

Scrolling through the QListView items !

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k Views 1 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.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #1

    I have a QListView which has a horizontal scroll bar. When I drag and drop an item, the scroll bar should move to the appropriate position as per the cursor position.

    this->horizontalScrollBar()->setSliderPosition(this->mapFromParent(QCursor::pos()).x());

    But when the mouse cursor is at the end of the viewport of the qlistview, scrolling stops. The problem is scroll bar doesnt get the "x" position at the end of the qlistview's viewport.

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      This is not trivial, since you cannot get mouse events if the drag for instance leaves the application window boundaries...
      the only possibility to overcome this problem would be to subclass qlistview, override "QAbstractItemView::startDrag()":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#startDrag and do the same like QListView does in there.
      Once the drag starts you need to poll the cursor position with a timer and adapt the scrolling.
      But this solution also only works for drags started in the list itself (no external drags).

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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