Hello,<br><br>I'm having problems displaying a widget as a child inside a window. The code below should create a window that is 500 x 500 with a red box inside 400 x 400.<br><br>If I replace self.ChildWidget = AppWidget( self ) with self.ChildWidget = QtGui.QWidget( self ) I get the desired result, what am I doing wrong with AppWidget( ) that would cause it not to display correctly?<br>
<br>from PyQt4 import QtCore, QtGui<br><br>class AppWidget( QtGui.QWidget ):<br> def __init__( self, parent = None ):<br> super( AppWidget, self ).__init__( parent )<br><br>class AppWindow( QtGui.QMainWindow ):<br>
def __init__( self ):<br> super( AppWindow, self ).__init__( )<br> self.setGeometry( 30, 30, 500, 500 )<br> <br> self.ChildWidget = AppWidget( self )<br> self.ChildWidget.setGeometry( 10, 10, 400, 400 )<br>
self.ChildWidget.setStyleSheet( "background-color: #ff0000" )<br><br>if __name__ == "__main__":<br> import sys<br><br> app = QtGui.QApplication( sys.argv )<br> MainWindow = AppWindow( )<br>
MainWindow.show( )<br> sys.exit( app.exec_( ) )<br clear="all"><br>-- <br>Best Regards,<br>Kurt Schwarz<br>