I am building an app with a gui in Pyqt5, and am trying to make it float above other windows, but it just won't work. I have tried setting other flags at the same time, but the only one that doesn't work is WindowStaysOnTopHint.
Here you have a simple example that I have been working with, FramelessWindowHint: fine, WindowStaysOnTopHint not working. I thought maybe this was a Linux thing, that it wouldn't enable it to be hard coded and had to be used through the menu of the window itself, but a similar program in Java works just fine, and the window stays on top.
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSizeGrip
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.title = "PyQt5 Size Grip"
self.top = 200
self.left = 500
self.width = 640
self.height = 480
self.setWindowTitle(self.title)
self.setWindowIcon(QtGui.QIcon("icon.png"))
self.setGeometry(self.left, self.top, self.width, self.height)
flags = QtCore.Qt.WindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlags(flags)
vboxlayout = QVBoxLayout()
sizegrip = QSizeGrip(self)
#sizegrip.setVisible(True)
vboxlayout.addWidget(sizegrip)
self.setLayout(vboxlayout)
self.show()
if __name__ == "__main__":
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
Any help here would be much appreciated, as this is a core feature and I would hate to have to rewrite this whole thing in Java :)