Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QStackedLayout Class Reference

The QStackedLayout class maintains a stack of widgets where only the top widget is visible. More...

    #include <QStackedLayout>

Inherits QLayout.

- List of all members, including inherited members

### Writable Properties

- currentIndex : int

- 3 writable properties inherited from QLayout
- 1 writable property inherited from QObject

### Read-Only Properties

- count : int

### Public Functions

- QStackedLayout ( QWidget * parent )
- QStackedLayout ( QLayout * parentLayout )
- ~QStackedLayout ()
- int addWidget ( QWidget * w )
- QWidget * currentWidget () const
- int indexOf ( QWidget * w ) const
- int insertWidget ( int index, QWidget * w )
- QWidget * widget ( int index ) const

- 21 public functions inherited from QLayout
- 24 public functions inherited from QObject
- 16 public functions inherited from QLayoutItem

### Public Slots

- 1 public slot inherited from QObject

### Signals

- void widgetRemoved ( int index )

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QObject

### Protected Functions

- 4 protected functions inherited from QLayout
- 9 protected functions inherited from QObject

## Detailed Description

The QStackedLayout class maintains a stack of widgets where only the top widget is visible.

QStackedLayout places all the widgets it is responsible for on top of each other, so only the top one is visible to the user at any one time. Widget positions are given by positive integer indexes starting at 0; the widget on top has index position 0.

Widgets are added at the the end of the stack with addWidget(), or inserted in the stack with insertWidget(). The current widget is returned by currentWidget(), and its index is returned by currentIndex(). The index position of a given widget is returned by indexOf(), and the widget at a given index position by widget(). The number of widgets in the stack is returned by count(). The top widget is set with setCurrentIndex(). If a widget is removed (e.g. with QLayout::removeWidget()), the widgetRemoved() signal is emitted.

See also QStackedBox.

## Property Documentation

### count : int

Access functions:

- int count () const

### currentIndex : int

This property holds the index position of the current widget.

The current index is -1 if there is no current widget, for example if the stack is empty.

Access functions:

- int currentIndex () const
- void setCurrentIndex ( int )

See also currentWidget() and indexOf().

## Member Function Documentation

### QStackedLayout::QStackedLayout ( QWidget * parent )

Constructs a new QStackedLayout with the given parent.

### QStackedLayout::QStackedLayout ( QLayout * parentLayout )

Constructs a new QStackedLayout and inserts it into the given parentLayout.

### QStackedLayout::~QStackedLayout ()

Destroys this QStackedLayout.

The layout's widgets are not destroyed.

### int QStackedLayout::addWidget ( QWidget * w )

Adds widget w at the end of this layout stack and returns the index position of w.

The very first widget that is added becomes the initial current widget and is placed in index position 0 (i.e. on top).

See also insertWidget().

### QWidget * QStackedLayout::currentWidget () const

Returns the current widget, or 0 if there are no widgets in this layout. Equivalent to `widget(currentIndex())`.

### int QStackedLayout::indexOf ( QWidget * w ) const

Returns the index position of widget w in this layout, or -1 if w is not in this layout.

### int QStackedLayout::insertWidget ( int index, QWidget * w )

Inserts widget w to this layout at position index. If index is out of range, the widget is appended. Returns the index position of w.

The very first widget that is added becomes the initial current widget and is placed in index position 0 (i.e. on top).

See also addWidget().

### QWidget * QStackedLayout::widget ( int index ) const

Returns the widget at position index, or 0 if there is no widget at the given position.

### void QStackedLayout::widgetRemoved ( int index ) `[signal]`

This signal is emitted if a widget is removed from the stack, e.g. with QLayout::removeWidget(). The position that the removed widget occupied in the stack is given by index.