python - how to catch drop event in QtableWidget in pyqt -


i have window 3 table widgets designed using qt designer.

table 1. display groups present

table 2. display employees (drag enabled setto true)

table 3. display employees in selected group (acceptdrops set true)

i want catch drop event on table 3. after drop has performed want run function. , @ same time should avoid duplicates in drop.

i have set eventfilters

table3.installeventfilter(self) 

but not able catch drop event.

my eventfilter def below

def eventfilter(self, object, event):     if (object self.tblw_groupmembers):         if (event.type() == qtcore.qevent.dragenter):             if event.mimedata().hasurls():                 event.accept()   # must accept dragenterevent or else dropevent can't occur !!!                 print "accept"             else:                 event.ignore()                 print "ignore"         if (event.type() == qtcore.qevent.drop):             print 'drop'         return false # lets event continue edit     return false 

i have followed process posted thread

able catch dragenter not drop

i believe need handle (and accept) qtcore.qevent.dragmove events. should add handler dragleave think less important.

unfortunately requirement doesn't seem documented well, i've observed similar behaviour when i've implemented drag-and-drop. personally, typically override dragenterevent(), dragmoveevent() , dropevent() methods of widget in question (rather installing event filter) principle same (and expect solution same).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -