[Qgis-developer] qWebView in a plugin - the windows closes
immediately
Martin Dobias
wonder.sk at gmail.com
Tue May 11 11:01:52 EDT 2010
On Tue, May 11, 2010 at 4:34 PM, baobazz <baobazz at hotmail.fr> wrote:
>
> I've got problems with the web windows: it automatically closes..
>
> [...]
>
> def run(self):
> #code to get the layer_id
> view=QWebView()
> url="http://info_layer.php?layer="+layer_id
> view.load(QUrl(url))
> view.show()
The problem is that the "view" object is valid only within the context
of run() method - it gets destroyed automatically when the method is
finished. You can set the "view" object to be an attribute of the
class, i.e. self.view = QWebView(). This will destroy the view when
the plugin instance is deleted. Other possibility is to set parent of
the QWebView instance - the ownership will be transferred to the
parent and it will be deleted when the parent is deleted - see QObject
reference.
Martin
More information about the Qgis-developer
mailing list