[Qt-interest] activateWindow weirdness (or PEBKAC?)

Stanislav Ochotnicky sochotnicky at redhat.com
Mon May 10 15:34:53 CEST 2010


Hi,

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, but I have re-created even with QWidget) 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 and window is created on top of other
(older windows). This seems wrong, since documentation for
activateWindow does not specify any conditions under which something
like this could happen. It just does exact opposite to what it's
supposed to do...

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 these focusing issues? I tried searching Jira for any
open/closed bugs regarding activateWindow but none of them were similar
to this.

Thanks,

-- 
Stanislav Ochotnicky <sochotnicky at redhat.com>
Associate Software Engineer - Base Operating Systems Brno

PGP: 71A1677C
Red Hat Inc.                               http://cz.redhat.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100510/0a838d34/attachment.bin 


More information about the Qt-interest-old mailing list