QToolBox Class

QToolBox 提供一列选项widget. 更多...

头文件: #include <QToolBox>
qmake: QT += widgets
基类: QFrame

属性

公有函数

QToolBox(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags())
~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)
  • 19 个公有槽函数继承自 QWidget
  • 1 个公有槽函数继承自 QObject

信号

void currentChanged(int index)

受保护的函数

virtual void itemInserted(int index)
virtual void itemRemoved(int index)

重新实现的受保护函数

virtual void changeEvent(QEvent *ev)
virtual bool event(QEvent *e)
virtual void showEvent(QShowEvent *e)
  • 4 个受保护的函数继承自 QFrame
  • 35 个受保护的函数继承自 QWidget
  • 9 个受保护的函数继承自 QObject
  • 1 个受保护的函数继承自 QPaintDevice

其他继承的成员

  • 1 个公有变量继承自 QObject
  • 5 个静态公有成员继承自 QWidget
  • 10 个静态公有成员继承自 QObject
  • 1 个受保护的槽函数继承自 QWidget
  • 2 个受保护的变量继承自 QObject
  • 1 protected type inherited from QPaintDevice

详细描述

QToolBox 提供一列选项widget.

工具箱是一个显示以列排布的多选项widget, 当前选项显示在选项标签的下方. 每个选项标签具有列表中的索引位置. 一个选项是一个 QWidget.

每个选项都有一个 itemText(), 一个可选的 itemIcon(), 一个可选的 itemToolTip()和一个 widget(). 调用 setItemText(), setItemIcon() 和 setItemToolTip()更改选项的属性. 每个选项调用 setItemEnabled()开启或禁用.

调用 addItem()增加选项, 调用 insertItem()插入选项. 调用 count()获取选项数量. 调用 removeItem()删除选项. 调用 removeItem() 和 insertItem() 移动选项到其他位置.

调用 currentIndex()返回当前选项, 调用 setCurrentIndex()设置当前选项. 调用 indexOf()查询选项索引, 调用 item()查找选项.

当前选项改变时发送信号 currentChanged().

参见 QTabWidget.

属性

count : const int

This property holds the number of items contained in the toolbox.

By default, this property has a value of 0.

访问函数:

int count() const

currentIndex : int

This property holds the index of the current item

By default, for an empty toolbox, this property has a value of -1.

访问函数:

int currentIndex() const
void setCurrentIndex(int index)

Notifier signal:

void currentChanged(int index)

参见 indexOf() and widget().

成员函数

QToolBox::QToolBox(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags())

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

QToolBox::~QToolBox()

Destroys the toolbox.

int QToolBox::addItem(QWidget *widget, const QIcon &iconSet, const QString &text)

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(QWidget *w, const QString &text)

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.

[virtual protected] void QToolBox::changeEvent(QEvent *ev)

重新实现 QWidget::changeEvent().

[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.

QWidget *QToolBox::currentWidget() const

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

参见 currentIndex() and setCurrentWidget().

[virtual protected] bool QToolBox::event(QEvent *e)

重新实现 QObject::event().

int QToolBox::indexOf(QWidget *widget) const

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

int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text)

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(int index, QWidget *widget, const QString &text)

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(int index) const

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

QIcon QToolBox::itemIcon(int index) const

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

参见 setItemIcon().

[virtual protected] void QToolBox::itemInserted(int index)

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

参见 itemRemoved().

[virtual protected] void QToolBox::itemRemoved(int index)

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

参见 itemInserted().

QString QToolBox::itemText(int index) const

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

参见 setItemText().

QString QToolBox::itemToolTip(int index) const

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

参见 setItemToolTip().

void QToolBox::removeItem(int index)

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

[slot] void QToolBox::setCurrentWidget(QWidget *widget)

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

参见 addItem(), setCurrentIndex(), and currentWidget().

void QToolBox::setItemEnabled(int index, bool enabled)

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

参见 isItemEnabled().

void QToolBox::setItemIcon(int index, const QIcon &icon)

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

参见 itemIcon().

void QToolBox::setItemText(int index, const 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 '&&').

参见 itemText().

void QToolBox::setItemToolTip(int index, const QString &toolTip)

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

参见 itemToolTip().

[virtual protected] void QToolBox::showEvent(QShowEvent *e)

重新实现 QWidget::showEvent().

QWidget *QToolBox::widget(int index) const

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