[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] 'mouseMoveEvent' for a 'QListWidget' subclass stops
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2011-11-22 11:31:39
Message-ID: 9ab627d78e5f93ec0e99203bae0d3686 () localhost
[Download RAW message or body]

On Tue, 22 Nov 2011 11:12:21 +0000, "Timothy W. Grove" <tim_grove@sil.org>
wrote:
> Why would reimplementing a 'mouseMoveEvent' for a 'QListWidget' subclass

> stop drag-and-drop?
> 
> The class below just holds a list of icons. Without the mouseMoveEvent 
> method I can drag the icons around; with it I can't. Under wxPython I 
> would have added 'event.skip()' at the end of my event handling method 
> and expected the method to pass on the event when it finished. Is there 
> something similar under PyQt4?
> 
> class ItemList(QListWidget):
>      def __init__(self, parent=None):
>          super(ItemList, self).__init__(parent)
>          self.setViewMode(QListView.IconMode)
>          self.setResizeMode(QListView.Adjust)
>          self.setMouseTracking(True)
>          self.current_item = None
>          self.setDragEnabled(True)
>          self.setAcceptDrops(True)
> 
>      def mouseMoveEvent(self, event):
>          item = self.itemAt(event.pos())
>          if item != self.current_item:
>              self.emit(SIGNAL("item_found"), item)
>              self.current_item = item

Call the super-class method at the end of your reimplementation.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic