当QDialog居中时,为什么QMainWindow在左上角?

时间:2019-02-03 18:46:56

标签: python-3.x pyqt5 qmainwindow qdialog

我不明白为什么默认情况下将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居中。

0 个答案:

没有答案