简体   繁体   中英

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...?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM