I'm trying to get the screen position of QMainWindow and print the position (x,y) values. I have tried both self.pos() and self.mapToGlobal(self.pos()) and both of these return 0.
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)
# PRINTS 0 0
print(self.pos().x(), self.pos().y())
# PRINTS 0 0
print(self.mapToGlobal(self.pos()).x(), self.mapToGlobal(self.pos()).y())
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
I'm using Python 3.7 and PyQt 5.11, how can I achieve this?
