setWindowFlagsをメソッドとコンストラクタで設定する方法
setWindowFlagsメソッドの引数かコンストラクタの引数にWindow Flagsをセットすることで設定できます。
setWindowFlagsメソッドの引数での設定方法
メソッドの引数での設定方法
#!/usr/bin/env python # -*- coding: utf-8 -*- try: from PySide.QtGui import * from PySide.QtCore import * except: from PySide2.QtWidgets import * from PySide2.QtGui import * from PySide2.QtCore import * class example(QMainWindow): def __init__(self): super(example, self).__init__() self.setWindowFlags(Qt.WindowCloseButtonHint) self.initUI() def initUI(self): self.show() def main(): app = QApplication.instance() ex = example() sys.exit() app.exec_() if __name__ == '__main__': main()
コンストラクタの引数での設定方法
#!/usr/bin/env python # -*- coding: utf-8 -*- try: from PySide.QtGui import * from PySide.QtCore import * except: from PySide2.QtWidgets import * from PySide2.QtGui import * from PySide2.QtCore import * class example(QMainWindow): def __init__(self, parent=None): super(example, self).__init__(parent, flags=Qt.WindowCloseButtonHint) self.initUI() def initUI(self): self.show() def main(): app = QApplication.instance() ex = example() sys.exit() app.exec_() if __name__ == '__main__': main()
それぞれメリットデメリットがありますが
活用してみてください!
ディスカッション
コメント一覧
まだ、コメントがありません