I'm trying to break away from having all my widgets and my main window in one user interface file. So in the example below I've created a frame that I want to show up in the main window. Later on I will show and hide it along with other frames etc. It pops up but in its own window and only briefly. What am I doing wrong? How do I get the QFrame UI file I created in Qt Designer to behave like what I would expect? That is to say a frame and not frame inside a window? I've excluded the boilerplate code that pyuic4 generates.

myApp.py:

Qt Code:
  1. import sys
  2. from PyQt4 import QtCore, QtGui
  3. from main_window import Ui_MainWindow
  4. from frame2 import Frame
  5.  
  6. class StartQt4(QtGui.QMainWindow, Ui_MainWindow):
  7. def __init__(self):
  8. super(self.__class__, self).__init__()
  9. self.setupUi(self)
  10. myFrame = Frame()
  11. myFrame.show()
  12.  
  13. if __name__ == "__main__":
  14. app = QtGui.QApplication(sys.argv)
  15. mainWin = StartQt4()
  16. mainWin.show()
  17. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 
main_window.py:
Qt Code:
  1. class Ui_MainWindow(object):
  2. def setupUi(self, MainWindow):
  3. MainWindow.setObjectName(_fromUtf8("MainWindow"))
  4. MainWindow.resize(640, 480)
  5. self.centralwidget = QtGui.QWidget(MainWindow)
  6. self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
  7. self.label = QtGui.QLabel(self.centralwidget)
  8. self.label.setGeometry(QtCore.QRect(155, 45, 146, 81))
  9. self.label.setObjectName(_fromUtf8("label"))
  10. MainWindow.setCentralWidget(self.centralwidget)
  11. self.statusbar = QtGui.QStatusBar(MainWindow)
  12. self.statusbar.setObjectName(_fromUtf8("statusbar"))
  13. MainWindow.setStatusBar(self.statusbar)
  14.  
  15. self.retranslateUi(MainWindow)
  16. QtCore.QMetaObject.connectSlotsByName(MainWindow)
  17.  
  18. def retranslateUi(self, MainWindow):
  19. MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
  20. self.label.setText(_translate("MainWindow", "Main Window without menu bar", None))
To copy to clipboard, switch view to plain text mode 
frame2.py:

Qt Code:
  1. class Ui_Frame(object):
  2. def setupUi(self, Frame):
  3. Frame.setObjectName(_fromUtf8("Frame"))
  4. Frame.resize(320, 240)
  5. Frame.setFrameShape(QtGui.QFrame.Box)
  6. Frame.setFrameShadow(QtGui.QFrame.Plain)
  7. Frame.setLineWidth(8)
  8. self.label = QtGui.QLabel(Frame)
  9. self.label.setGeometry(QtCore.QRect(100, 60, 141, 76))
  10. self.label.setObjectName(_fromUtf8("label"))
  11.  
  12. self.retranslateUi(Frame)
  13. QtCore.QMetaObject.connectSlotsByName(Frame)
  14.  
  15. def retranslateUi(self, Frame):
  16. Frame.setWindowTitle(_translate("Frame", "Frame", None))
  17. self.label.setText(_translate("Frame", "This is the frame", None))
  18.  
  19. class Frame(QtGui.QFrame, Ui_Frame):
  20. def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()):
  21. QtGui.QFrame.__init__(self, parent, f)
  22.  
  23. self.setupUi(self)
To copy to clipboard, switch view to plain text mode