[Qgis-developer] In a QGIS plugin, can't start a thread from a QDockWidget control...

Luc Lamoureux llamou at gmail.com
Thu Jul 31 07:16:41 PDT 2014


I have to convert a QGIS plugin (2.2.0-Valmiera 32 bits) from a QDialog to
a QDockWidget. While succeeding in doing the conversion (the plugin is now
docked), the threads which are launched from the plugin do not work
anymore. Any idea why this happens and how to solve this? Here is an
example showing my problem using only a QPushButton that starts a thread:

First, my plugDockDialog.py file:

class PlugDockDialog(QDockWidget, Ui_PlugDock): def __init__(self):
QDockWidget.__init__(self, None) self.setupUi(self)

and (the significant parts of) my plugDock.py file:

class PlugDock: def __init__(self, iface): self.iface = iface self.dlg =
PlugDockDialog() self.iface.addDockWidget( Qt.RightDockWidgetArea, self.dlg
) cmd = self.dlg.findChild(QPushButton,"cmdGo")
cmd.clicked.connect(self.cmdGoClick) # Thread method @staticmethod def
myfunc(i): time.sleep(3) print "Docking thread %d is finished..." % i #
Click method def cmdGoClick(self): t = Thread(target=self.myfunc,
args=(1,)) t.start()

Thank you for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140731/45f7e472/attachment-0001.html>


More information about the Qgis-developer mailing list