gpt4 book ai didi

python - 弃用警告 : Function when moving app (removed titlebar) - PySide6

转载 作者:行者123 更新时间:2023-12-04 12:55:53 24 4
gpt4 key购买 nike

当我移动应用程序时,我收到此警告:

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()
有没有办法跳过这个警告?它有效,但这个警告很烦人。

最佳答案

这对我有用:

p = event.globalPosition()
globalPos = p.toPoint()
例如,您可以像这样使用:
def mousePressEvent(self, event):
p = event.globalPosition()
globalPos = p.toPoint()
self.dragPos = globalPos

关于python - 弃用警告 : Function when moving app (removed titlebar) - PySide6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67723421/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com