整个框架
import sys
from PySide6 import QtWidgets, QtCore, QtGui
from PySide6.QtCore import Qt, QRect
from PySide6.QtGui import QColor, QEnterEvent
from PySide6.QtWidgets import QApplication, QDialog, QMainWindow, QGraphicsDropShadowEffect
import yiqi_ui
class MainWindow(QMainWindow,yiqi_ui.Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.win = yiqi_ui.Ui_MainWindow()
self.win.setupUi(self)
self.setWindowFlag(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.show()
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton and self.isMaximized() == False:
self.m_flag = True
self.m_Position = event.globalPos() - self.pos()
event.accept()
self.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
def mouseMoveEvent(self, mouse_event):
if QtCore.Qt.LeftButton and self.m_flag:
self.move(mouse_event.globalPos() - self.m_Position)
mouse_event.accept()
def mouseReleaseEvent(self, mouse_event):
self.m_flag = False
self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
if __name__ == '__main__':
app = QApplication(sys.argv)
win = MainWindow()
win.show()
app.exec()