[PyQt] What am I doing wrong with QWidget?
Kurt Schwarz
kurtschwarz at gmail.com
Sat Sep 19 19:27:06 BST 2009
Hello,
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.
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?
from PyQt4 import QtCore, QtGui
class AppWidget( QtGui.QWidget ):
def __init__( self, parent = None ):
super( AppWidget, self ).__init__( parent )
class AppWindow( QtGui.QMainWindow ):
def __init__( self ):
super( AppWindow, self ).__init__( )
self.setGeometry( 30, 30, 500, 500 )
self.ChildWidget = AppWidget( self )
self.ChildWidget.setGeometry( 10, 10, 400, 400 )
self.ChildWidget.setStyleSheet( "background-color: #ff0000" )
if __name__ == "__main__":
import sys
app = QtGui.QApplication( sys.argv )
MainWindow = AppWindow( )
MainWindow.show( )
sys.exit( app.exec_( ) )
--
Best Regards,
Kurt Schwarz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090919/349fc206/attachment.html
More information about the PyQt
mailing list