当我移动应用程序时,会出现此警告:
C:\Qt\Login_Test\main.py:48: DeprecationWarning: Function: 'globalPos() const' is marked as deprecated, please check the documentation for more information.
self.dragPos = event.globalPos()
C:\Qt\Login_Test\main.py:43: DeprecationWarning: Function: 'globalPos() const' is marked as deprecated, please check the documentation for more information.
self.move(self.pos() + event.globalPos() - self.dragPos)
C:\Qt\Login_Test\main.py:44: DeprecationWarning: Function: 'globalPos() const' is marked as deprecated, please check the documentation for more information.
self.dragPos = event.globalPos()
我使用了这段代码:
self.remove_title()
self.ui.appname_label.mouseMoveEvent = self.move_window
def remove_title(self):
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(20)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 250))
self.ui.frame.setGraphicsEffect(self.shadow)
def move_window(self, event):
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
有没有办法跳过这个警告?它可以运行,但是这个警告很烦人。
globalPos
已经被globalPosition
替换了,它可能返回浮点数而不是整数作为位置。 - KempglobalPosition()
。而且,正如所说的那样,这只是一个“警告”。 - musicamante