from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtCore
from MainWindow import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(154, 125)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 0, 115, 104))
self.label.setText("")
self.label.setPixmap(QtGui.QPixmap("./压缩.gif"))
self.label.setScaledContents(True)
self.label.setObjectName("label")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
# 设置窗口的相关特性(隐藏窗口标题栏,且设置为最顶层的窗口)
#self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
Dialog.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
# 窗口背景透明,但是别的还显示
Dialog.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
if __name__=='__main__':
import sys
app=QtWidgets.QApplication(sys.argv)
app.setStyle('Fusion')
MainWindow=QtWidgets.QDialog()
ui=Ui_Dialog()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
请问如何实现鼠标拖动此悬浮窗?
已知一般的重写窗口类自带的三个函数没用任何效果,