[Qgis-developer] qWebView in a plugin - the windows closes immediately

baobazz baobazz at hotmail.fr
Tue May 11 10:34:29 EDT 2010


Hello,

I'd like to make a plugin that displays metadata of the current layer from a
web page..

For the development, I used a test plugin and modified the run function to
incorporate my code into it

I've got problems with the web windows: it automatically closes..

Here is the code:

# -*- coding: utf-8 -*-
import sys
import sqlite3
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from qgis.core import *

from ui_control import ui_Control
import resources_rc

class TestPlugin:

  def __init__(self, iface):
    self.iface = iface

  def initGui(self):
    # create action that will start plugin configuration
    self.action = QAction(QIcon(":/icon.png"), "Test plugin",
self.iface.mainWindow())
    self.action.setWhatsThis("Configuration for test plugin")
    self.action.setStatusTip("This is status tip")

    # connect the action to the run method
    QObject.connect(self.action, SIGNAL("activated()"), self.run)

    # add toolbar button and menu item
    self.iface.addToolBarIcon(self.action)
    self.iface.addPluginToMenu("&Test Plugin", self.action)

  def unload(self):
    # remove the plugin menu item and icon
    self.iface.removePluginMenu("&Test Plugin",self.action)
    self.iface.removeToolBarIcon(self.action)

  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()

Any help would be appreciated
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/qWebView-in-a-plugin-the-windows-closes-immediately-tp5036265p5036265.html
Sent from the qgis-developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list