Reputation: 2599
I am debugging certain application written with C++/Qt4. On Linux it has problems that with certain window managers (gnome-wm/metacity), the main window (based on QDialog) is created in the background (it's not raised). I managed to re-create the scenario using PyQt4 and following code:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class PinDialog(QDialog):
def showEvent(self, event):
QDialog.showEvent(self, event)
self.raise_()
self.activateWindow()
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = PinDialog()
app.setActiveWindow(widget)
widget.exec_()
sys.exit(0)
If I remove
self.activateWindow()
the application works as expected. This seems wrong, since documentation for activateWindow does not specify any conditions under which something like this could happen.
My question is: Is there any reason to have activateWindow in showEvent in the first place? If there is some reason, what would be good workaround for focusing issues?
Upvotes: 1
Views: 1186
Reputation: 2599
The problem was most probably caused by a bug in Qt. I can't reproduce the same behaviour in recent Qt versions. Originally reproduced on Fedora 13, Fedora 14 works OK.
Upvotes: 0
Reputation: 141998
I. too, have seen this behaviour.
According to the documentation:
On X11, the result depends on the Window Manager
It appears that Gnome is taking the same stance as Microsoft Windows in not allowing an application to interrupt what the user is currently doing in another application (in this case Terminal).
Upvotes: 1