[PyKDE] dialog/mainwindow question

Garrett G. Hodgson garry at kestrel.sage.att.com
Fri Feb 14 16:02:01 GMT 2003


i've been flailing around trying to get a dialog up.
in the code below, until i figured out to add the call
to setCentralWidget(), i'd get a big window with a little
tiny QTextView in the upper left corner.  once i added the
setCentralWidget() call, the QTextView fills the whole window,
as intended.

before i switched WTF to be a subclass of QMainWindow, it
was a QDialog, as in the commented out code.  but i'd get
similarly weird results with that.

so, i can leave this as a QMainWindow, but it feeles like it
really oughta be a QDialog.  is there something i can add to
the QDialog to make this work?  and is there a rule of thumb
for when to use one vs. the other?

thanks

-----------------------------------
#!/usr/bin/env python2

import sys
from qt import *

#class WTF( QDialog ):
#	def __init__( self, parent ):
#		QDialog.__init__( self, parent, 'WTF', 0 )

class WTF( QMainWindow ):
	def __init__( self, parent ):
		QMainWindow.__init__( self, parent, 'WTF' )

		body = QTextView( self )
		body.setText( 'this is some text\nthis is some more text' )
		self.setCentralWidget( body )

def main():
	app = QApplication( sys.argv )
	QObject.connect( app, SIGNAL( 'lastWindowClosed()' ), app, SLOT( 'quit()' ) )

	mainWin = WTF( None )

	app.setMainWidget( mainWin )
	mainWin.show()
	app.exec_loop()

main()




More information about the PyQt mailing list