pythonpyqtsplash-screenstayontop

Splash window and always on top at the same time in pyqt4?


In pyqt4, I can use setWindowFlags(Qt.SplashScreen) so the window have no title bar.

And use setWindowFlags(Qt.WindowStaysOnTopHint) to make window always stays on top.

But what if I want them both? No title bar and stays on top at the same time.

Is there a way to achieve that...?


Solution

  • Whenever you want to apply multiple flags, you should use the | operator, which is the binary or operator. This will allow multiple flags as @ekhumoro said, so a simple example would be:

    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    import sys
    
    class MyWindow(QMainWindow):
        def __init__(self):
            QMainWindow.__init__(self)
            self.resize(640,480)
            self.setWindowFlags(Qt.SplashScreen | Qt.WindowStaysOnTopHint)
    
    if __name__=="__main__":
        app=QApplication(sys.argv)
        win=MyWindow()
        win.show()
        sys.exit(app.exec_())