|  | Home · All Classes · Modules

# QToolBox Class Reference
[QtGui module]

The QToolBox class provides a column of tabbed widget items. More...

Inherits QFrame.

### Methods

- __init__ (self, QWidget parent = None, Qt.WindowFlags flags = 0)
- int addItem (self, QWidget item, QString text)
- int addItem (self, QWidget item, QIcon iconSet, QString text)
- changeEvent (self, QEvent)
- int count (self)
- int currentIndex (self)
- QWidget currentWidget (self)
- bool event (self, QEvent e)
- int indexOf (self, QWidget widget)
- int insertItem (self, int index, QWidget item, QString text)
- int insertItem (self, int index, QWidget widget, QIcon icon, QString text)
- bool isItemEnabled (self, int index)
- QIcon itemIcon (self, int index)
- itemInserted (self, int index)
- itemRemoved (self, int index)
- QString itemText (self, int index)
- QString itemToolTip (self, int index)
- removeItem (self, int index)
- setCurrentIndex (self, int index)
- setCurrentWidget (self, QWidget widget)
- setItemEnabled (self, int index, bool enabled)
- setItemIcon (self, int index, QIcon icon)
- setItemText (self, int index, QString text)
- setItemToolTip (self, int index, QString toolTip)
- showEvent (self, QShowEvent e)
- QWidget widget (self, int index)

### Special Methods

- __len__ (self)

### Qt Signals

- void currentChanged (int)

## Detailed Description

The QToolBox class provides a column of tabbed widget items.

A toolbox is a widget that displays a column of tabs one above the other, with the current item displayed below the current tab. Every tab has an index position within the column of tabs. A tab's item is a QWidget.

Each item has an itemText(), an optional itemIcon(), an optional itemToolTip(), and a widget(). The item's attributes can be changed with setItemText(), setItemIcon(), and setItemToolTip(). Each item can be enabled or disabled individually with setItemEnabled().

Items are added using addItem(), or inserted at particular positions using insertItem(). The total number of items is given by count(). Items can be deleted with delete, or removed from the toolbox with removeItem(). Combining removeItem() and insertItem() allows you to move items to different positions.

The index of the current item widget is returned by currentIndex(), and set with setCurrentIndex(). The index of a particular item can be found using indexOf(), and the item at a given index is returned by item().

The currentChanged() signal is emitted when the current item is changed.

## Method Documentation

### QToolBox.__init__ (self, QWidget parent = None, Qt.WindowFlags flags = 0)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new toolbox with the given parent and the flags, f.

### int QToolBox.addItem (self, QWidget item, QString text)

The item argument has it's ownership transferred to Qt.

Adds the widget in a new tab at bottom of the toolbox. The new tab's text is set to text, and the iconSet is displayed to the left of the text. Returns the new tab's index.

### int QToolBox.addItem (self, QWidget item, QIcon iconSet, QString text)

The item argument has it's ownership transferred to Qt.

This is an overloaded function.

Adds the widget w in a new tab at bottom of the toolbox. The new tab's text is set to text. Returns the new tab's index.

### QToolBox.changeEvent (self, QEvent)

Reimplemented from QWidget.changeEvent().

### int QToolBox.count (self)

### int QToolBox.currentIndex (self)

### QWidget QToolBox.currentWidget (self)

Returns a pointer to the current widget, or 0 if there is no such item.

See also currentIndex() and setCurrentWidget().

### bool QToolBox.event (self, QEvent e)

Reimplemented from QObject.event().

### int QToolBox.indexOf (self, QWidget widget)

Returns the index of widget, or -1 if the item does not exist.

### int QToolBox.insertItem (self, int index, QWidget item, QString text)

The item argument has it's ownership transferred to Qt.

Inserts the widget at position index, or at the bottom of the toolbox if index is out of range. The new item's text is set to text, and the icon is displayed to the left of the text. Returns the new item's index.

### int QToolBox.insertItem (self, int index, QWidget widget, QIcon icon, QString text)

The widget argument has it's ownership transferred to Qt.

This is an overloaded function.

Inserts the widget at position index, or at the bottom of the toolbox if index is out of range. The new item's text is set to text. Returns the new item's index.

### bool QToolBox.isItemEnabled (self, int index)

Returns true if the item at position index is enabled; otherwise returns false.

### QIcon QToolBox.itemIcon (self, int index)

Returns the icon of the item at position index, or a null icon if index is out of range.

See also setItemIcon().

### QToolBox.itemInserted (self, int index)

This virtual handler is called after a new item was added or inserted at position index.

See also itemRemoved().

### QToolBox.itemRemoved (self, int index)

This virtual handler is called after an item was removed from position index.

See also itemInserted().

### QString QToolBox.itemText (self, int index)

Returns the text of the item at position index, or an empty string if index is out of range.

See also setItemText().

### QString QToolBox.itemToolTip (self, int index)

Returns the tooltip of the item at position index, or an empty string if index is out of range.

See also setItemToolTip().

### QToolBox.removeItem (self, int index)

Removes the item at position index from the toolbox. Note that the widget is not deleted.

### QToolBox.setCurrentIndex (self, int index)

This method is also a Qt slot with the C++ signature `void setCurrentIndex(int)`.

### QToolBox.setCurrentWidget (self, QWidget widget)

This method is also a Qt slot with the C++ signature `void setCurrentWidget(QWidget*)`.

Makeswidget the current widget. The widget must be an item in this tool box.

See also addItem(), setCurrentIndex(), and currentWidget().

### QToolBox.setItemEnabled (self, int index, bool enabled)

If enabled is true then the item at position index is enabled; otherwise the item at position index is disabled.

See also isItemEnabled().

### QToolBox.setItemIcon (self, int index, QIcon icon)

Sets the icon of the item at position index to icon.

See also itemIcon().

### QToolBox.setItemText (self, int index, QString text)

Sets the text of the item at position index to text.

If the provided text contains an ampersand character ('&'), a mnemonic is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous mnemonic will be overwritten, or cleared if no mnemonic is defined by the text. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

See also itemText().

### QToolBox.setItemToolTip (self, int index, QString toolTip)

Sets the tooltip of the item at position index to toolTip.

See also itemToolTip().

### QToolBox.showEvent (self, QShowEvent e)

Reimplemented from QWidget.showEvent().

### QWidget QToolBox.widget (self, int index)

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

### QToolBox.__len__ (self)

## Qt Signal Documentation

### void currentChanged (int)

This is the default overload of this signal.

This signal is emitted when the current item is changed. The new current item's index is passed in index, or -1 if there is no current item.