[PyQt] Strange behavior on windowCloseRequested on QWeView

Thomaz de Oliveira dos Reis thor27 at gmail.com
Wed Oct 19 19:36:13 BST 2011


Hi,

I have this simple code:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

def close(): sys.exit()

app = QApplication(sys.argv)

web = QWebView()
QObject.connect(web.page(),SIGNAL("windowCloseRequested ()"),close)

web.load(QUrl("a.html"))
web.show()

sys.exit(app.exec_())

and 2 more files, that is a.html:
<a href="b.html">link to B</a><br/>
<a href="#" onclick="window.close()">close this window</a>

and b.html:
<a href="a.html">link to A</a><br/>
<a href="#" onclick="window.close()">close this window</a>

When you load the app, and then clicks on "close this window" the window closes
But if you click on link to B and then click on "close this window"
the window doesn't closes.

Why this happens? There is any solution so this signals keep working
even after loading another URL?


thanks!


More information about the PyQt mailing list