The QToolBox class provides a column of tabbed widget items. More...
Header: | #include <QToolBox> |
qmake: | QT += widgets |
Inherits: | QFrame |
QToolBox(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) | |
virtual | ~QToolBox() |
int | addItem(QWidget *widget, const QIcon &iconSet, const QString &text) |
int | addItem(QWidget *w, const QString &text) |
int | count() const |
int | currentIndex() const |
QWidget * | currentWidget() const |
int | indexOf(QWidget *widget) const |
int | insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text) |
int | insertItem(int index, QWidget *widget, const QString &text) |
bool | isItemEnabled(int index) const |
QIcon | itemIcon(int index) const |
QString | itemText(int index) const |
QString | itemToolTip(int index) const |
void | removeItem(int index) |
void | setItemEnabled(int index, bool enabled) |
void | setItemIcon(int index, const QIcon &icon) |
void | setItemText(int index, const QString &text) |
void | setItemToolTip(int index, const QString &toolTip) |
QWidget * | widget(int index) const |
void | setCurrentIndex(int index) |
void | setCurrentWidget(QWidget *widget) |
void | currentChanged(int index) |
virtual void | itemInserted(int index) |
virtual void | itemRemoved(int index) |
virtual void | changeEvent(QEvent *ev) override |
virtual bool | event(QEvent *e) override |
virtual void | showEvent(QShowEvent *e) override |
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.
See also QTabWidget.
This property holds the number of items contained in the toolbox.
By default, this property has a value of 0.
Access functions:
int | count() const |
This property holds the index of the current item
By default, for an empty toolbox, this property has a value of -1.
Access functions:
int | currentIndex() const |
void | setCurrentIndex(int index) |
Notifier signal:
void | currentChanged(int index) |
Constructs a new toolbox with the given parent and the flags, f.
[signal]
void QToolBox::currentChanged(int index)
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.
Note: Notifier signal for property currentIndex.
[slot]
void QToolBox::setCurrentWidget(QWidget *widget)
Makeswidget the current widget. The widget must be an item in this tool box.
See also addItem(), setCurrentIndex(), and currentWidget().
[virtual]
QToolBox::~QToolBox()
Destroys the toolbox.
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.
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.
[override virtual protected]
void QToolBox::changeEvent(QEvent *ev)
Reimplements: QFrame::changeEvent(QEvent *ev).
Returns a pointer to the current widget, or nullptr
if there is no such item.
See also currentIndex() and setCurrentWidget().
[override virtual protected]
bool QToolBox::event(QEvent *e)
Reimplements: QFrame::event(QEvent *e).
Returns the index of widget, or -1 if the item does not exist.
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.
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.
Returns true
if the item at position index is enabled; otherwise returns false
.
Returns the icon of the item at position index, or a null icon if index is out of range.
See also setItemIcon().
[virtual protected]
void QToolBox::itemInserted(int index)
This virtual handler is called after a new item was added or inserted at position index.
See also itemRemoved().
[virtual protected]
void QToolBox::itemRemoved(int index)
This virtual handler is called after an item was removed from position index.
See also itemInserted().
Returns the text of the item at position index, or an empty string if index is out of range.
See also setItemText().
Returns the tooltip of the item at position index, or an empty string if index is out of range.
See also setItemToolTip().
Removes the item at position index from the toolbox. Note that the widget is not deleted.
If enabled is true then the item at position index is enabled; otherwise the item at position index is disabled.
See also isItemEnabled().
Sets the icon of the item at position index to icon.
See also itemIcon().
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().
Sets the tooltip of the item at position index to toolTip.
See also itemToolTip().
[override virtual protected]
void QToolBox::showEvent(QShowEvent *e)
Reimplements: QWidget::showEvent(QShowEvent *event).
Returns the widget at position index, or nullptr
if there is no such item.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qtoolbox.html