QToolBox 类

QToolBox 类提供选项卡化 Widget 项的列。 更多...

头: #include <QToolBox>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: 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 (const 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 (),可选 itemIcon (),可选 itemToolTip (), and a widget (). The item's attributes can be changed with setItemText (), setItemIcon (),和 setItemToolTip (). Each item can be enabled or disabled individually with setItemEnabled ().

Items are added using addItem (),或插入在特定位置使用 insertItem (). The total number of items is given by count (). Items can be deleted with delete, or removed from the toolbox with removeItem ()。组合 removeItem () 和 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.

另请参阅 QTabWidget .

特性文档编制

[read-only] count : const int

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

默认情况下,此特性拥有 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 )

通知程序信号:

void currentChanged (int index )

另请参阅 indexOf () 和 widget ().

成员函数文档编制

[explicit] QToolBox:: QToolBox ( QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())

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

[virtual noexcept] QToolBox:: ~QToolBox ()

Destroys the toolbox.

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

添加 widget in a new tab at bottom of the toolbox. The new tab's text is set to text ,和 iconSet is displayed to the left of the text 。返回新选项卡的索引。

int QToolBox:: addItem ( QWidget * w , const QString & text )

这是重载函数。

Adds the widget w in a new tab at bottom of the toolbox. The new tab's text is set to text 。返回新选项卡的索引。

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

重实现: QFrame::changeEvent (QEvent *ev).

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

注意: 通知程序信号对于特性 currentIndex .

QWidget *QToolBox:: currentWidget () const

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

另请参阅 currentIndex () 和 setCurrentWidget ().

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

重实现: QFrame::event (QEvent *e).

int QToolBox:: indexOf (const QWidget * widget ) const

返回索引对于 widget , or -1 if the item does not exist.

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

插入 widget 在位置 index , or at the bottom of the toolbox if index is out of range. The new item's text is set to text ,和 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 )

这是重载函数。

插入 widget 在位置 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

返回 true if the item at position index 被启用;否则返回 false .

QIcon QToolBox:: itemIcon ( int index ) const

Returns the icon of the item at position index ,或 null 图标若 index 超出范围。

另请参阅 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 ,或空字符串若 index 超出范围。

另请参阅 setItemText ().

QString QToolBox:: itemToolTip ( int index ) const

Returns the tooltip of the item at position index ,或空字符串若 index 超出范围。

另请参阅 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 )

使 widget 当前小部件。 widget must be an item in this tool box.

另请参阅 addItem (), setCurrentIndex (),和 currentWidget ().

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

enabled is true then the item at position index 被启用;否则项在位置 index 被禁用。

另请参阅 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 文档编制了解细节 (要显示实际和号,使用 &&)。

另请参阅 itemText ().

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

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

另请参阅 itemToolTip ().

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

重实现: QWidget::showEvent (QShowEvent *event).

QWidget *QToolBox:: widget ( int index ) const

Returns the widget at position index ,或 nullptr if there is no such item.