Python - How do i remove the window border? I have imported UI from Qt into Python and applied setWindowFlags
Question: How to make this window Border-less (remove minimize/maximize/close)?

![enter image description here](http://i.stack.imgur.com/j68tz.png)

    
    
      1 import sys
      2 from PyQt4 import QtCore, QtGui
      3 from qt import Ui_MainWindow
      4 
      5 class StartQT4(QtGui.QMainWindow):
      6     def __init__(self, parent=None):
      7         QtGui.QWidget.__init__(self, parent)
      8         self.ui = Ui_MainWindow()
      9         self.ui.setupUi(self))
     10         
     11 if __name__ == "__main__":
     12     app = QtGui.QApplication(sys.argv)
     13     myapp = StartQT4()
     14     myapp.show()
     15     app.setWindowFlags(app.FramelessWindowHint) <<< does not working
     16     sys.exit(app.exec_())
     17     
    


Answer: You need to set the window flag before calling `show` on the main window.

A minimal working example would look like this:

    
    
    import sys
    from PyQt4 import QtCore, QtGui
    
    class StartQT4(QtGui.QMainWindow):
        def __init__(self, parent=None):
            super(StartQT4, self).__init__(parent)
            self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
            self.b = QtGui.QPushButton("exit", self, clicked=self.close)
    
    if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        myapp = StartQT4()
        myapp.show()
        sys.exit(app.exec_())
    

