QToolBox Class

QToolBoxクラスは、タブウィジェット項目の列を提供します。詳細...

ヘッダー #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

詳細説明

ツールボックスは、タブの列を他のタブの上に表示するウィジェットで、現在のアイテムは現在のタブの下に表示されます。すべてのタブは、タブの列内のインデックス位置を持っています。タブのアイテムはQWidget です。

各項目は、itemText ()、オプションのitemIcon ()、オプションのitemToolTip ()、widget ()を持ちます。アイテムの属性はsetItemText()、setItemIcon()、setItemToolTip() で変更できます。各項目はsetItemEnabled() で個別に有効/無効にできます。

項目はaddItem() で追加され、insertItem() で特定の位置に挿入される。項目の総数はcount() で指定する。アイテムは delete で削除でき、removeItem() でツールボックスから削除できます。removeItem() とinsertItem() を組み合わせると、アイテムを異なる位置に移動できます。

現在のアイテム・ウィジェットのインデックスは、currentIndex() で返され、setCurrentIndex() で設定されます。特定のアイテムのインデックスはindexOf() で見つけることができ、指定されたインデックスのアイテムは item() で返されます。

currentChanged() シグナルは、現在の項目が変更されたときに出力されます。

QTabWidgetも参照して ください。

プロパティのドキュメント

[read-only] count : const int

このプロパティは、ツールボックスに含まれるアイテムの数を保持する。

デフォルトでは、このプロパティの値は0である。

アクセス関数:

int count() const

currentIndex : int

このプロパティは、現在のアイテムのインデックスを保持する。

デフォルトでは、空のツールボックスの場合、このプロパティの値は -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())

与えられたparent とフラグf で新しいツールボックスを構築します。

[virtual noexcept] QToolBox::~QToolBox()

ツールボックスを破壊する。

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

ツールボックス下部の新しいタブにwidget を追加します。新しいタブのテキストはtext に設定され、iconSettext の左に表示されます。新しいタブのインデックスを返します。

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

これはオーバーロードされた関数です。

ツールボックスの下部にある新しいタブにウィジェットw を追加します。新しいタブのテキストはtext に設定されます。新しいタブのインデックスを返します。

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

再インプリメント:QFrame::changeEvent(QEvent *ev).

[signal] void QToolBox::currentChanged(int index)

このシグナルは現在のアイテムが変更されたときに発せられる。新しい現在のアイテムのインデックスがindex に渡され、現在のアイテムがない場合は -1 が渡される。

注: プロパティcurrentIndex に対するノーティファイア・シグナル。

QWidget *QToolBox::currentWidget() const

現在のウィジェットへのポインタを返し、そのような項目がない場合はnullptr を返します。

currentIndex() およびsetCurrentWidget()も参照してください

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

再インプリメント:QFrame::event(QEvent *e).

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

widget のインデックスを返し、アイテムが存在しない場合は -1 を返す。

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

index の位置にwidget を挿入し、index が範囲外の場合はツールボックスの一番下に挿入する。新しい項目のテキストはtext に設定され、icontext の左に表示されます。 新しい項目のインデックスを返します。

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

これはオーバーロードされた関数です。

index の位置にwidget を挿入します。index が範囲外の場合はツールボックスの一番下に挿入します。新しい項目のテキストはtext に設定されます。新しい項目のインデックスを返します。

bool QToolBox::isItemEnabled(int index) const

位置index のアイテムが有効な場合はtrue を返し、そうでない場合はfalse を返す。

QIcon QToolBox::itemIcon(int index) const

位置index にあるアイテムのアイコン、またはindex が範囲外の場合は null アイコンを返します。

setItemIcon()も参照

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

この仮想ハンドラは、新しいアイテムがindex の位置に追加または挿入された後に呼び出される。

itemRemoved()も参照のこと

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

この仮想ハンドラは、アイテムがindex の位置から取り除かれた後に呼び出される。

itemInserted()も参照のこと

QString QToolBox::itemText(int index) const

位置index にある項目のテキスト、またはindex が範囲外の場合は空文字列を返します。

setItemText()も参照

QString QToolBox::itemToolTip(int index) const

位置index にある項目のツールチップ、またはindex が範囲外の場合は空の文字列を返す。

setItemToolTip()も参照

void QToolBox::removeItem(int index)

位置index のアイテムをツールボックスから削除する。ウィジェットは削除されないことに注意してください。

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

widget を現在のウィジェットにする。widget は、このツールボックスのアイテムでなければならない。

addItem(),setCurrentIndex(),currentWidget()も参照

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

もしenabled が真なら、index の位置の項目が有効になる。そうでなければ、index の位置の項目が無効になる。

isItemEnabled()も参照のこと

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

位置index にあるアイテムのアイコンをicon に設定する。

itemIcon()も参照

void QToolBox::setItemText(int index, const QString &text)

位置index にある項目のテキストをtext に設定する。

指定されたテキストにアンパサンド文字 ('&') が含まれている場合、ニーモニックが自動的に作成される。に続く文字がショートカットキーとして使われる。以前のニーモニックは上書きされ、テキストでニーモニックが定義されていない場合はクリアされる。詳細はQShortcut のドキュメントを参照のこと(実際のアンパサンドを表示するには '&&' を使う)。

itemText()も参照のこと

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

位置index にあるアイテムのツールチップをtoolTip に設定します。

itemToolTip()も参照

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

再実装:QWidget::showEvent(QShowEvent *event)。

QWidget *QToolBox::widget(int index) const

位置index にあるウィジェットを返し、そのようなアイテムがない場合はnullptr を返します。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.