DeprecationWarning: Function when moving app (removed titlebar) - PySide6

2024/11/16 19:46:23

I get when I move the App this Warning:

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()

I used this code:

        self.remove_title()self.ui.appname_label.mouseMoveEvent = self.move_windowdef 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()

Is there a way to skip this warning? It works but this warning is annoying.

Answer

This works for me:

p = event.globalPosition()
globalPos = p.toPoint()

For example, you can use like this:

def mousePressEvent(self, event):p = event.globalPosition()globalPos = p.toPoint()self.dragPos = globalPos
https://en.xdnf.cn/q/71300.html

Related Q&A

Architecture solution for Python Web application

Were setting up a Python REST web application. Right now, were using WSGI, but we might do some changes to that in the future (using Twisted, for example, to improve on scalability or some other featu…

Capture image for processing

Im using Python with PIL and SciPy. i want to capture an image from a webcam then process it further using numpy and Scipy. Can somebody please help me out with the code.Here is the code there is a pre…

Loading Magnet LINK using Rasterbar libtorrent in Python

How would one load a Magnet link via rasterbar libtorrent python binding?

Python currying with any number of variables

I am trying to use currying to make a simple functional add in Python. I found this curry decorator here.def curry(func): def curried(*args, **kwargs):if len(args) + len(kwargs) >= func.__code__…

Python - Display rows with repeated values in csv files

I have a .csv file with several columns, one of them filled with random numbers and I want to find duplicated values there. In case there are - strange case, but its what I want to check after all -, I…

Defining __getattr__ and __getitem__ on a function has no effect

Disclaimer This is just an exercise in meta-programming, it has no practical purpose.Ive assigned __getitem__ and __getattr__ methods on a function object, but there is no effect...def foo():print &quo…

thread._local object has no attribute

I was trying to change the logging format by adding a context filter. My Format is like thisFORMAT = "%(asctime)s %(VAL)s %(message)s"This is the class I use to set the VAL in the format. cla…

Pytorch batch matrix vector outer product

I am trying to generate a vector-matrix outer product (tensor) using PyTorch. Assuming the vector v has size p and the matrix M has size qXr, the result of the product should be pXqXr.Example:#size: 2 …

Scraping Google Analytics by Scrapy

I have been trying to use Scrapy to get some data from Google Analytics and despite the fact that Im a complete Python newbie I have made some progress. I can now login to Google Analytics by Scrapy b…

Pandas representative sampling across multiple columns

I have a dataframe which represents a population, with each column denoting a different quality/ characteristic of that person. How can I get a sample of that dataframe/ population, which is representa…