我不明白为什么默认情况下将QDialog
放在中心位置而将QMainWindow
放在左上角?
示例代码:
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("MainWindow")
class Dialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Dialog")
if __name__ == "__main__":
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
dialog = Dialog()
dialog.show()
sys.exit(app.exec_())
默认情况下,我希望使用QMainWindow
居中。