# QLayout Class Reference

The QLayout class is the base class of geometry specifiers. More...

`#include <qlayout.h>`

Inherits QObject.

Inherited by QBoxLayout and QGridLayout.

List of all member functions.

## Public Members

- virtual ~QLayout ()
- int defaultBorder () const
- enum { unlimited = QCOORD_MAX }
- virtual bool activate ()
- void freeze ( int w, int h )
- void freeze ()
- void setMenuBar ( QMenuBar * w )
- QWidget* mainWidget ()

## Protected Members

- QLayout ( QWidget * parent, int border, int autoBorder, const char * name )
- QLayout ( int autoBorder = -1, const char * name=0 )
- QGManager* basicManager ()
- virtual QChain* mainVerticalChain ()
- virtual QChain* mainHorizontalChain ()
- virtual void initGM ()
- void addChildLayout ( QLayout * )

## Static Protected Members

- QChain* verChain ( QLayout * l )
- QChain* horChain ( QLayout * l )

## Detailed Description

The QLayout class is the base class of geometry specifiers.

This is an abstract base class. The concrete layout managers QBoxLayout and QGridLayout inherit from this one and make QLayout's functionality avaialble in friendly APIs.

Most users of Q*Layout are likely to use some of the basic functions provided by QLayout, such as

- activate(), which compiles the layout into an internal representation and activates the result,
- setMenuBar(), which is necessary to manage a menu bar because of the special properties of menu bars, and
- freeze(), which allows you to freeze the widget's size and layout.

Geometry management stops when the layout manager is deleted.

To make a new layout manager, you need to implement the functions mainVerticalChain(), mainHorizontalChain() and initGM().

## Member Function Documentation

### QLayout::QLayout ( QWidget * parent, int border, int autoBorder, const char * name ) `[protected]`

Creates a new top-level QLayout with main widget parent. parent may not be 0.

border is the number of pixels between the edge of the widget and the managed children. autoBorder sets the value of defaultBorder(), which is interpreted by subclasses. If autoBorder is -1 the value of border is used.

name is the internal object name

Having several top-level layouts for the same widget will cause considerable confusion.

### QLayout::QLayout ( int autoBorder = -1, const char * name=0 ) `[protected]`

Constructs a new child QLayout, If autoBorder is -1, this QLayout inherits parent's defaultBorder(), otherwise autoBorder is used.

### QLayout::~QLayout () `[virtual]`

Deletes all children layouts. Geometry management stops when a toplevel layout is deleted.

### bool QLayout::activate () `[virtual]`

Starts geometry management - analogous to show() for widgets. This function should only be called for top level layouts.

Examples: pref/pref.cpp layout/layout.cpp widgets/widgets.cpp

### void QLayout::addChildLayout ( QLayout * l ) `[protected]`

This function is called from addLayout functions in subclasses, to add l layout as a sublayout.

### QGManager * QLayout::basicManager () `[protected]`

Returns the QGManager for this layout. Returns 0 if this is a child layout which has not been inserted yet.

### int QLayout::defaultBorder () const

Returns the default border for the geometry manager.

### void QLayout::freeze ( int w, int h )

Fixes the size of the main widget and distributes the available space to the child widgets. For widgets which should not be resizable, but where a QLayout subclass is used to set up the initial geometry.

A frozen layout cannot be unfrozen, the only sensible thing to do is to delete it.

The size is adjusted to a valid value. Thus freeze(0,0) fixes the widget to its minimum size.

### void QLayout::freeze ()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This version of the method fixes the main widget at its minimum size. You can also achieve this with freeze( 0, 0 );.

### QChain * QLayout::horChain ( QLayout * ) `[static protected]`

This function works around a dubious feature in the C++ language definition, to provide access to mainHorizontalChain().

### void QLayout::initGM () `[virtual protected]`

Implement this function to do what's necessary to initialize chains, once the layout has a basicManager().

Reimplemented in QGridLayout and QBoxLayout.

### QChain * QLayout::mainHorizontalChain () `[virtual protected]`

Implement this function to return the main horizontal chain.

Reimplemented in QGridLayout and QBoxLayout.

### QChain * QLayout::mainVerticalChain () `[virtual protected]`

Implement this function to return the main vertical chain.

Reimplemented in QGridLayout and QBoxLayout.

### QWidget * QLayout::mainWidget ()

Returns the main widget of this layout, or 0 if this layout is a sub-layout which is not yet inserted.

### void QLayout::setMenuBar ( QMenuBar * w )

Makes the geometry manager take account of the menu bar w. All child widgets are placed below the bottom edge of the menu bar.

A menu bar does its own geometry managing, never do addWidget() on a menu bar.

Examples: widgets/widgets.cpp

### QChain * QLayout::verChain ( QLayout * ) `[static protected]`

This function works around a dubious feature in the C++ language definition, to provide access to mainVerticalChain().

Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):

This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.

It was generated from the following files:

- qlayout.h: 1998/08/21
- qlayout.cpp: 1998/09/21