Maya custom window placed at the top and not topped and window transparent

#the first method
From PySide2 import QtGui, QtWidgets, QtCore
Class OptionWidget(QtWidgets.QWidget):
    Closed = QtCore.Signal()

    Def __init__(self, *args, **kwargs):
        Super(OptionWidget, self).__init__(*args, **kwargs)

        mainLayout =QtWidgets.QVBoxLayout(self)

        Button = QtWidgets.QPushButton('Close', self)
        Button.clicked.connect(self.__close)
        mainLayout.addWidget(button)
        mainLayout.addStretch(True)


    Def __close(self):
        Self.closed.emit()

Class DraggableWindow(mayaMixin.MayaQWidgetBaseMixin, QtWidgets.QMainWindow):
    Def __init__(self, *args, **kwargs):
        Super(DraggableWindow, self).__init__(*args, **kwargs)
        #self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

        optionWidget = OptionWidget(self)
        optionWidget.closed.connect(self.close)
        self.setCentralWidget(optionWidget)

        statusBar = self.statusBar()

        Self.__isDrag = False
        Self.__startPos = QtCore.QPoint(0, 0)
        Self.resize(200,100)
        Self.move(300,300)


    Def mousePressEvent(self, event):
        Self.__isDrag = True
        Self.__startPos = event.pos()
        Super(DraggableWindow, self).mousePressEvent(event)

    Def mouseReleaseEvent(self, event):
        Self.__isDrag = False
        Super(DraggableWindow, self).mouseReleaseEvent(event)

    Def mouseMoveEvent(self, event):
        If self.__isDrag:
            Self.move(self.mapToParent(event.pos() - self.__startPos))
        Super(DraggableWindow, self).mouseMoveEvent(event)


Window = DraggableWindow()
Window.show()

#The second method
From PySide2 import QtGui, QtWidgets, QtCore

Class OptionWidget(QtWidgets.QWidget):
    Closed = QtCore.Signal()

    Def __init__(self, parent=None):
        Super(OptionWidget, self).__init__(parent)

        mainLayout =QtWidgets.QVBoxLayout(self)

        Button = QtWidgets.QPushButton('Close', self)
        Button.clicked.connect(self.__close)
        mainLayout.addWidget(button)
        mainLayout.addStretch(True)


    Def __close(self):
        Self.closed.emit()

Class DraggableWindow(QtWidgets.QMainWindow):
    parentUI=QtWidgets.QApplication.activeWindow()
    Def __init__(self, parent=parentUI):
        Super(DraggableWindow, self).__init__(parent)
        #self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

        optionWidget = OptionWidget(self)
        optionWidget.closed.connect(self.close)
        self.setCentralWidget(optionWidget)

        statusBar = self.statusBar()

        Self.__isDrag = False
        Self.__startPos = QtCore.QPoint(0, 0)
        Self.resize(200,100)
        Self.move(300,300)


    Def mousePressEvent(self, event):
        Self.__isDrag = True
        Self.__startPos = event.pos()
        Super(DraggableWindow, self).mousePressEvent(event)

    Def mouseReleaseEvent(self, event):
        Self.__isDrag = False
        Super(DraggableWindow, self).mouseReleaseEvent(event)

    Def mouseMoveEvent(self, event):
        If self.__isDrag:
            Self.move(self.mapToParent(event.pos() - self.__startPos))
        Super(DraggableWindow, self).mouseMoveEvent(event)


Window = DraggableWindow()
Window.show()

这里写图片描述

If the custom window is not pinned, the custom window will be placed at the bottom when working on other windows. After that, it is very inconvenient to use it again and again. You can solve this problem by using these two methods.

Where #self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

This sentence is to set the window transparent, because it affects the screenshot, so the comment.