[PyQt] drop action locks up drag source application

Dennis Gidudu dennis.gid at gmail.com
Tue Feb 23 10:14:21 GMT 2010

I'm fairly new to PyQt, so this may be a newbie question, but I just
can't figure it out.

I have a widget that receives drop events from other applications. The
drop event triggers an action that could take quite a lot of time to
finish. I use a modal QProgressDialog to display the progress. Problem
is that the application from which the drag source originated freezes
until the action is completed, making it unusable for several minutes.
Can anyone explain what I am doing wrong? Any help is appreciated.

I'm Running PyQt 4.7 with Python 2.6 on Windows 7.

import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class DropperWidget(QLabel):
	def __init__(self, *args, **kwargs):
		QLabel.__init__(self, *args, **kwargs)
		self.setFixedSize(200, 200)
		self.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
	def dragEnterEvent(self, e):
	def dropEvent(self, e):

def someLongRunningAction():
	progress_dialog = QProgressDialog('Working...', 'Cancel', 0, 1000000, dropper)
	while progress_dialog.value() < progress_dialog.maximum() - 1:
		if progress_dialog.wasCanceled():
		progress_dialog.setValue(progress_dialog.value() + 1)

app = QApplication(sys.argv)
dropper = DropperWidget('Drop Stuff Here')
dropper.connect(dropper, SIGNAL('dropped_something()'), someLongRunningAction)


More information about the PyQt mailing list