简单的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位置的坐标?