Pyside2 modal window doesn't stay on top


#1

Hi,

I’m having trouble keeping my pyside2 window on top in Maya. Here’s the code:

from PySide2 import QtWidgets, QtUiTools, QtCore
import sys

class UI_Test(QtWidgets.QMainWindow):
    def __init__(self, parent):
        super(UI_Test, self).__init__(parent)
        loader = QtUiTools.QUiLoader()
        self.ui = loader.load('ui_file.ui')
        self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)

my_app = UI_Test(parent=QtWidgets.QApplication.activeWindow())
my_app.setWindowModality(QtCore.Qt.WindowModal)
my_app.ui.show()

I’ve done this successfully in the past but I’m not sure what’s wrong this time. Anything I’m missing here?

Thanks!


#2

I got it sorted. I forgot that it need to be ‘self.ui.setWindowsFlags’ instead of ‘self.setwindowFlags’.

One other thing though. In the past when I’ve done this I could minimize the modal window to the bottom of the screen. Now if I minimize it just hides the panel behind the main window. How can I get it to truly minimize?

Thanks!


#3

Actually, I figured that out too. Nothing to see here! :slight_smile: