PyQt5 MainWindow获取相对于屏幕的位置

时间:2018-08-24 14:35:04

标签: python-3.x pyqt5

简单的QMainWindow实现和太多的谷歌搜索时间,我需要知道主窗口相对于屏幕的XY坐标是什么。此实现始终显示0,0:

import sys

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.uic import loadUi

class TestReportsApp(QMainWindow):
    def __init__(self, parent=None):
        super(TestReportsApp, self).__init__(parent)
        loadUi('test.ui', self)

    @pyqtSlot()
    def showEvent(self, e):
        print(self.geometry())

app = QApplication(sys.argv)
mainWin = TestReportsApp()
mainWin.show()
sys.exit(app.exec_())

如何获取主窗口相对于屏幕的左上XY位置的坐标?

0 个答案:

没有答案