[PyKDE] dialog/mainwindow question

Boudewijn Rempt boud at valdyas.org
Fri Feb 14 17:03:01 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 14 February 2003 16:00, Garrett G. Hodgson wrote:
> 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?
>

A QDialog typically is used for a dialog window -- that is,
a popup with a number of fields that are carefully arranged.
That careful arrangement is your job; using either QDesigner
(which I recommend), or manual messing with QLayout and
descendant (see the docs), you arrange buttons, radiobuttons,
text fields and spinners.

A QMainWindow is the main window of your aplication: where 
you find the text in an editor, the cells in a spreadsheet
or the piccy in a CAD app. Generally speaking, the area
between the toolbar and the statusbar is occupied by a single
widget -- and QMainWindow is a QDialog (to simplify things)
with a layout manager that manages the menubar, the toolbars,
the statusbar, and that single widget between toolbars and
statusbar.

I discuss this issue quite extensively in my book: have you seen it?

(In case not: http://www.opendocs.org/pyqt -- if you find it useful,
please buy a paper copy. The publisher has put it under an open content
license, meaning that everything is available on the website, except,
because of a technical snafu, the screenshots, but so far sales haven't
paid for the bandwidth of the website.)

- -- 
Boudewijn Rempt | http://www.valdyas.org/index2.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+TRMWdaCcgCmN5d8RAq9kAKDlUzrbc8n83HgPmYEhPXIJ02Z6dgCfV048
R+QiXZWu239yfW8QODrIX7M=
=43I7
-----END PGP SIGNATURE-----




More information about the PyQt mailing list