PDA

View Full Version : autoscroll on drag



Michael_Levin
17th January 2011, 23:09
Hello!
Help me please what's going on:
i want to have auto-scroll in my QListWidget during drag-n-drop operation, so when the dragged item is at the bottom or at the top of viewport, the listwidget should scroll. Everything is ok by default - setAutoScroll(True), setAcceptDrops(True), etc.

When i add my code: (anything unusual, just for me)


def startDrag(self):
items = self.selectedItems()
if bool(items):
icon = items[0].icon()
data = QByteArray()
stream = QDataStream(data, QIODevice.WriteOnly)
stream << QString(', '.join(map(lambda x: unicode(x.text()), items)))
mimeData = QMimeData()
mimeData.setData("application/x-text", data)
drag = QDrag(self)
drag.setMimeData(mimeData)
pixmap = icon.pixmap(24,24)
drag.setHotSpot(QPoint(12,12))
drag.setPixmap(pixmap)
drag.exec_(Qt.MoveAction)

def mouseMoveEvent(self, ev):
self.startDrag()
QWidget.mouseMoveEvent(self, ev)

the autoscroll disappears. Why? Should i write my own auto-scroll, catch the point at the top and so on? I want to code less)
So, what's the reason?