Eneboo - Documentación para desarrolladores
Tipos públicos | Métodos públicos | Métodos protegidos | Propiedades
Referencia de la Clase QLayout

The QLayout class is the base class of geometry managers. Más...

#include <qlayout.h>

Diagrama de herencias de QLayout
QObject QLayoutItem QObject QLayoutItem Qt Qt Qt Qt QBoxLayout QBoxLayout QDockAreaLayout QDockAreaLayout QGridLayout QGridLayout QMainWindowLayout QwtDynGridLayout

Lista de todos los miembros.

Tipos públicos

enum  ResizeMode {
  FreeResize, Minimum, Fixed, Auto,
  FreeResize, Minimum, Fixed, Auto
}
enum  ResizeMode {
  FreeResize, Minimum, Fixed, Auto,
  FreeResize, Minimum, Fixed, Auto
}

Métodos públicos

 QLayout (QWidget *parent, int margin=0, int spacing=-1, const char *name=0)
 QLayout (QLayout *parentLayout, int spacing=-1, const char *name=0)
 QLayout (int spacing=-1, const char *name=0)
 ~QLayout ()
int margin () const
int spacing () const
virtual void setMargin (int)
virtual void setSpacing (int)
int defaultBorder () const
void freeze (int w, int h)
void freeze ()
void setResizeMode (ResizeMode)
ResizeMode resizeMode () const
virtual void setMenuBar (QMenuBar *w)
QMenuBarmenuBar () const
QWidgetmainWidget ()
bool isTopLevel () const
virtual void setAutoAdd (bool)
bool autoAdd () const
void invalidate ()
QRect geometry () const
bool activate ()
void add (QWidget *w)
virtual void addItem (QLayoutItem *)=0
void remove (QWidget *w)
void removeItem (QLayoutItem *)
QSizePolicy::ExpandData expanding () const
QSize minimumSize () const
QSize maximumSize () const
void setGeometry (const QRect &)=0
QLayoutIterator iterator ()=0
bool isEmpty () const
int totalHeightForWidth (int w) const
QSize totalMinimumSize () const
QSize totalMaximumSize () const
QSize totalSizeHint () const
QLayoutlayout ()
bool supportsMargin () const
void setEnabled (bool)
bool isEnabled () const
 QLayout (QWidget *parent, int margin=0, int spacing=-1, const char *name=0)
 QLayout (QLayout *parentLayout, int spacing=-1, const char *name=0)
 QLayout (int spacing=-1, const char *name=0)
 ~QLayout ()
int margin () const
int spacing () const
virtual void setMargin (int)
virtual void setSpacing (int)
int defaultBorder () const
void freeze (int w, int h)
void freeze ()
void setResizeMode (ResizeMode)
ResizeMode resizeMode () const
virtual void setMenuBar (QMenuBar *w)
QMenuBarmenuBar () const
QWidgetmainWidget ()
bool isTopLevel () const
virtual void setAutoAdd (bool)
bool autoAdd () const
void invalidate ()
QRect geometry () const
bool activate ()
void add (QWidget *w)
virtual void addItem (QLayoutItem *)=0
void remove (QWidget *w)
void removeItem (QLayoutItem *)
QSizePolicy::ExpandData expanding () const
QSize minimumSize () const
QSize maximumSize () const
void setGeometry (const QRect &)=0
QLayoutIterator iterator ()=0
bool isEmpty () const
int totalHeightForWidth (int w) const
QSize totalMinimumSize () const
QSize totalMaximumSize () const
QSize totalSizeHint () const
QLayoutlayout ()
bool supportsMargin () const
void setEnabled (bool)
bool isEnabled () const

Métodos protegidos

bool eventFilter (QObject *, QEvent *)
void childEvent (QChildEvent *e)
void addChildLayout (QLayout *l)
void deleteAllItems ()
void setSupportsMargin (bool)
QRect alignmentRect (const QRect &) const
bool eventFilter (QObject *, QEvent *)
void childEvent (QChildEvent *e)
void addChildLayout (QLayout *l)
void deleteAllItems ()
void setSupportsMargin (bool)
QRect alignmentRect (const QRect &) const

Propiedades

int margin
 the width of the outside border of the layout
int spacing
 the spacing between widgets inside the layout
ResizeMode resizeMode
 the resize mode of the layout

Descripción detallada

The QLayout class is the base class of geometry managers.

This is an abstract base class inherited by the concrete classes, QBoxLayout and QGridLayout.

For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setResizeMode() or setMenuBar(). See the layout overview page for more information.

To make your own layout manager, subclass QGLayoutIterator and implement the functions addItem(), sizeHint(), setGeometry(), and iterator(). You should also implement minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the custom layout page for an in-depth description.

Geometry management stops when the layout manager is deleted.


Documentación de las enumeraciones miembro de la clase

The possible values are:

Auto If the main widget is a top-level widget with no height-for-width (hasHeightForWidth()), this is the same as Minimium; otherwise, this is the same as FreeResize. Fixed The main widget's size is set to sizeHint(); it cannot be resized at all. Minimum The main widget's minimum size is set to minimumSize(); it cannot be smaller. FreeResize The widget is not constrained.

Valores de enumeraciones:
FreeResize 
Minimum 
Fixed 
Auto 
FreeResize 
Minimum 
Fixed 
Auto 
Valores de enumeraciones:
FreeResize 
Minimum 
Fixed 
Auto 
FreeResize 
Minimum 
Fixed 
Auto 

Documentación del constructor y destructor

QLayout::QLayout ( QWidget parent,
int  margin = 0,
int  spacing = -1,
const char *  name = 0 
)

Constructs a new top-level QLayout called name, with main widget parent. parent may not be 0.

The margin is the number of pixels between the edge of the widget and the managed children. The spacing sets the value of spacing(), which gives the spacing between the managed widgets. If spacing is -1 (the default), spacing is set to the value of margin.

There can be only one top-level layout for a widget. It is returned by QWidget::layout()

QLayout::QLayout ( QLayout parentLayout,
int  spacing = -1,
const char *  name = 0 
)

Constructs a new child QLayout called name, and places it inside parentLayout by using the default placement defined by addItem().

If spacing is -1, this QLayout inherits parentLayout's spacing(), otherwise the value of spacing is used.

QLayout::QLayout ( int  spacing = -1,
const char *  name = 0 
)

Constructs a new child QLayout called name. If spacing is -1, this QLayout inherits its parent's spacing(); otherwise the value of spacing is used.

This layout has to be inserted into another layout before geometry management will work.

QLayout::~QLayout ( )
QLayout::QLayout ( QWidget parent,
int  margin = 0,
int  spacing = -1,
const char *  name = 0 
)
QLayout::QLayout ( QLayout parentLayout,
int  spacing = -1,
const char *  name = 0 
)
QLayout::QLayout ( int  spacing = -1,
const char *  name = 0 
)
QLayout::~QLayout ( )

Documentación de las funciones miembro

bool QLayout::activate ( )

Redoes the layout for mainWidget(). You should generally not need to call this because it is automatically called at the most appropriate times.

However, if you set up a QLayout for a visible widget without resizing that widget, you will need to call this function in order to lay it out.

Ver también:
QWidget::updateGeometry()
bool QLayout::activate ( )
void QLayout::add ( QWidget w) [inline]

Adds widget w to this layout in a manner specific to the layout. This function uses addItem().

void QLayout::add ( QWidget w) [inline]
void QLayout::addChildLayout ( QLayout l) [protected]

This function is called from addLayout() functions in subclasses to add layout l as a sub-layout.

void QLayout::addChildLayout ( QLayout l) [protected]
void QLayout::addItem ( QLayoutItem item) [pure virtual]

Implemented in subclasses to add an item. How it is added is specific to each subclass.

The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.

Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

virtual void QLayout::addItem ( QLayoutItem ) [pure virtual]
QRect QLayout::alignmentRect ( const QRect r) const [protected]

Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment().

The result is derived from sizeHint() and expanding(). It is never larger than r.

QRect QLayout::alignmentRect ( const QRect ) const [protected]
bool QLayout::autoAdd ( ) const [inline]

Returns TRUE if this layout automatically grabs all new mainWidget()'s new children and adds them as defined by addItem(); otherwise returns FALSE. This has effect only for top-level layouts, i.e. layouts that are direct children of their mainWidget().

autoAdd() is disabled by default.

Note that a top-level layout is not necessarily associated with the top-level widget.

Ver también:
setAutoAdd()
bool QLayout::autoAdd ( ) const [inline]
void QLayout::childEvent ( QChildEvent e) [protected, virtual]

Reimplementado de QObject.

void QLayout::childEvent ( QChildEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive child events.

Child events are sent to objects when children are inserted or removed.

Note that events with QEvent::type() QEvent::ChildInserted are posted (with {QApplication::postEvent()}) to make sure that the child's construction is completed before this function is called.

If a child is removed immediately after it is inserted, the ChildInserted event may be suppressed, but the ChildRemoved event will always be sent. In such cases it is possible that there will be a ChildRemoved event without a corresponding ChildInserted event.

If you change state based on ChildInserted events, call QWidget::constPolish(), or do

in functions that depend on the state. One notable example is QWidget::sizeHint().

Ver también:
event(), QChildEvent

Reimplementado de QObject.

int QLayout::defaultBorder ( ) const [inline]
int QLayout::defaultBorder ( ) const [inline]
void QLayout::deleteAllItems ( ) [protected]
void QLayout::deleteAllItems ( ) [protected]

Removes and deletes all items in this layout.

bool QLayout::eventFilter ( QObject o,
QEvent e 
) [protected, virtual]

Performs child widget layout when the parent widget is resized. Also handles removal of widgets and child layouts. e is the event the occurred on object o.

Reimplementado de QObject.

bool QLayout::eventFilter ( QObject ,
QEvent  
) [protected, virtual]

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.

Example:

    class MyMainWindow : public QMainWindow
    {
    public:
        MyMainWindow( QWidget *parent = 0, const char *name = 0 );

    protected:
        bool eventFilter( QObject *obj, QEvent *ev );

    private:
        QTextEdit *textEdit;
    };

    MyMainWindow::MyMainWindow( QWidget *parent, const char *name )
        : QMainWindow( parent, name )
    {
        textEdit = new QTextEdit( this );
        setCentralWidget( textEdit );
        textEdit->installEventFilter( this );
    }

    bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev )
    {
        if ( obj == textEdit ) {
            if ( e->type() == QEvent::KeyPress ) {
                QKeyEvent *k = (QKeyEvent*)ev;
                qDebug( "Ate key press %d", k->key() );
                return TRUE;
            } else {
                return FALSE;
            }
        } else {
            // pass the event on to the parent class
            return QMainWindow::eventFilter( obj, ev );
        }
    }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Atención:
If you delete the receiver object in this function, be sure to return TRUE. Otherwise, Qt will forward the event to the deleted object and the program might crash.
Ver también:
installEventFilter()

Reimplementado de QObject.

QSizePolicy::ExpandData QLayout::expanding ( ) const [virtual]

Implemented in subclasses to return the direction(s) this item "wants" to expand in (if any).

Implementa QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QDockWindowGridLayout, QMainWindowLayout y QwtDynGridLayout.

QSizePolicy::ExpandData QLayout::expanding ( ) const [virtual]

Returns whether this layout can make use of more space than sizeHint(). A value of Vertical or Horizontal means that it wants to grow in only one dimension, whereas BothDirections means that it wants to grow in both dimensions.

The default implementation returns BothDirections.

Implementa QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QDockWindowGridLayout, QMainWindowLayout y QwtDynGridLayout.

void QLayout::freeze ( int  w,
int  h 
)
void QLayout::freeze ( ) [inline]
void QLayout::freeze ( int  w,
int  h 
)
void QLayout::freeze ( ) [inline]
QRect QLayout::geometry ( ) const [virtual]

Implementa QLayoutItem.

QRect QLayout::geometry ( ) const [virtual]

Returns the rectangle covered by this layout item.

Implementa QLayoutItem.

void QLayout::invalidate ( ) [virtual]

Invalidates cached information. Reimplementations must call this.

Reimplementado de QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

void QLayout::invalidate ( ) [virtual]

Invalidates any cached information in this layout item.

Reimplementado de QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

bool QLayout::isEmpty ( void  ) const [virtual]

Implemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.

Implementa QLayoutItem.

Reimplementado en QwtDynGridLayout.

bool QLayout::isEmpty ( void  ) const [virtual]

Returns TRUE if this layout is empty. The default implementation returns FALSE.

Implementa QLayoutItem.

Reimplementado en QwtDynGridLayout.

bool QLayout::isEnabled ( ) const

Returns TRUE if the layout is enabled; otherwise returns FALSE.

Ver también:
setEnabled()
bool QLayout::isEnabled ( ) const
bool QLayout::isTopLevel ( ) const [inline]

Returns TRUE if this layout is a top-level layout, i.e. not a child of another layout; otherwise returns FALSE.

bool QLayout::isTopLevel ( ) const [inline]
QLayoutIterator QLayout::iterator ( ) [pure virtual]

Returns an iterator over this item's QLayoutItem children. The default implementation returns an empty iterator.

Reimplement this function in subclasses that can have children.

Reimplementado de QLayoutItem.

Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

QLayoutIterator QLayout::iterator ( ) [pure virtual]

Implemented in subclasses to return an iterator that iterates over this layout's children.

A typical implementation will be:

        QLayoutIterator MyLayout::iterator()
        {
            QGLayoutIterator *i = new MyLayoutIterator( internal_data );
            return QLayoutIterator( i );
        }

where MyLayoutIterator is a subclass of QGLayoutIterator.

Reimplementado de QLayoutItem.

Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

QLayout * QLayout::layout ( ) [virtual]

Reimplementado de QLayoutItem.

QLayout* QLayout::layout ( ) [virtual]

If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. This function provides type-safe casting.

Reimplementado de QLayoutItem.

QWidget * QLayout::mainWidget ( )

Returns the main widget (parent widget) of this layout, or 0 if this layout is a sub-layout that is not yet inserted.

QWidget* QLayout::mainWidget ( )
int QLayout::margin ( ) const [inline]
int QLayout::margin ( ) const [inline]
QSize QLayout::maximumSize ( ) const [virtual]

Implemented in subclasses to return the maximum size of this item.

Implementa QLayoutItem.

Reimplementado en QGridLayout, QBoxLayout, QGridLayout y QBoxLayout.

QSize QLayout::maximumSize ( ) const [virtual]

Returns the maximum size of this layout. This is the largest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().

The default implementation allows unlimited resizing.

Implementa QLayoutItem.

Reimplementado en QGridLayout, QBoxLayout, QGridLayout y QBoxLayout.

QMenuBar * QLayout::menuBar ( ) const [inline]

Returns the menu bar set for this layout, or 0 if no menu bar is set.

QMenuBar* QLayout::menuBar ( ) const [inline]
QSize QLayout::minimumSize ( ) const [virtual]

Implemented in subclasses to return the minimum size of this item.

Implementa QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout y QMainWindowLayout.

QSize QLayout::minimumSize ( ) const [virtual]

Returns the minimum size of this layout. This is the smallest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().

The default implementation allows unlimited resizing.

Implementa QLayoutItem.

Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout y QMainWindowLayout.

void QLayout::remove ( QWidget w)
void QLayout::remove ( QWidget widget)

Removes the widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.

Ver también:
removeItem(), QWidget::setGeometry(), add()
void QLayout::removeItem ( QLayoutItem )
void QLayout::removeItem ( QLayoutItem item)

Removes the layout item item from the layout. It is the caller's responsibility to delete the item.

Notice that item can be a layout (since QLayout inherits QLayoutItem).

Ver también:
remove(), addItem()
ResizeMode QLayout::resizeMode ( ) const
ResizeMode QLayout::resizeMode ( ) const
virtual void QLayout::setAutoAdd ( bool  ) [virtual]
void QLayout::setAutoAdd ( bool  b) [virtual]

If b is TRUE, auto-add is enabled; otherwise auto-add is disabled.

Atención:
If auto-add is enabled, you cannot set stretch factors on the child widgets until the widgets are actually inserted in the layout (after control returned to the event loop). We therefore recommend that you avoid the auto-add feature in new programs.
Ver también:
autoAdd()
void QLayout::setEnabled ( bool  enable)

Enables this layout if enable is TRUE, otherwise disables it.

An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.

By default all layouts are enabled.

Ver también:
isEnabled()
void QLayout::setEnabled ( bool  )
void QLayout::setGeometry ( const QRect r) [pure virtual]

This function is reimplemented in subclasses to perform layout.

The default implementation maintains the geometry() information given by rect r. Reimplementors must call this function.

Implementa QLayoutItem.

Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

void QLayout::setGeometry ( const QRect r) [pure virtual]

Implemented in subclasses to set this item's geometry to r.

Implementa QLayoutItem.

Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.

virtual void QLayout::setMargin ( int  ) [virtual]
void QLayout::setMargin ( int  margin) [virtual]
void QLayout::setMenuBar ( QMenuBar w) [virtual]

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 management: never do addWidget() on a QMenuBar.

virtual void QLayout::setMenuBar ( QMenuBar w) [virtual]
void QLayout::setResizeMode ( ResizeMode  mode)
void QLayout::setResizeMode ( ResizeMode  )
virtual void QLayout::setSpacing ( int  ) [virtual]
void QLayout::setSpacing ( int  spacing) [virtual]
void QLayout::setSupportsMargin ( bool  ) [protected]
void QLayout::setSupportsMargin ( bool  b) [protected]

Sets the value returned by supportsMargin(). If b is TRUE, margin() handling is implemented by the subclass. If b is FALSE (the default), QLayout will add margin() around top-level layouts.

If b is TRUE, margin handling needs to be implemented in setGeometry(), maximumSize(), minimumSize(), sizeHint() and heightForWidth().

Ver también:
supportsMargin()
int QLayout::spacing ( ) const [inline]
int QLayout::spacing ( ) const [inline]
bool QLayout::supportsMargin ( ) const [inline]
bool QLayout::supportsMargin ( ) const [inline]

Returns TRUE if this layout supports QLayout::margin on non-top-level layouts; otherwise returns FALSE.

Ver también:
margin
int QLayout::totalHeightForWidth ( int  w) const
int QLayout::totalHeightForWidth ( int  w) const
QSize QLayout::totalMaximumSize ( ) const
QSize QLayout::totalMaximumSize ( ) const
QSize QLayout::totalMinimumSize ( ) const
QSize QLayout::totalMinimumSize ( ) const
QSize QLayout::totalSizeHint ( ) const
QSize QLayout::totalSizeHint ( ) const

Documentación de propiedades

int QLayout::margin [read, write]

the width of the outside border of the layout

For some layout classes this property has an effect only on top-level layouts; QBoxLayout and QGridLayout support margins for child layouts. The default value is 0.

Ver también:
spacing
ResizeMode QLayout::resizeMode [read, write]

the resize mode of the layout

The default mode is Auto.

Ver también:
QLayout::ResizeMode
int QLayout::spacing [read, write]

the spacing between widgets inside the layout

The default value is -1, which signifies that the layout's spacing should not override the widget's spacing.

Ver también:
margin

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'