File indexing completed on 2026-10-05 09:30:13
0001
0002
0003
0004
0005 #ifndef QTOOLBOX_H
0006 #define QTOOLBOX_H
0007
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qframe.h>
0010 #include <QtGui/qicon.h>
0011
0012 QT_REQUIRE_CONFIG(toolbox);
0013
0014 QT_BEGIN_NAMESPACE
0015
0016 class QToolBoxPrivate;
0017
0018 class Q_WIDGETS_EXPORT QToolBox : public QFrame
0019 {
0020 Q_OBJECT
0021 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
0022 Q_PROPERTY(int count READ count)
0023
0024 public:
0025 explicit QToolBox(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
0026 ~QToolBox();
0027
0028 int addItem(QWidget *widget, const QString &text);
0029 int addItem(QWidget *widget, const QIcon &icon, const QString &text);
0030 int insertItem(int index, QWidget *widget, const QString &text);
0031 int insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text);
0032
0033 void removeItem(int index);
0034
0035 void setItemEnabled(int index, bool enabled);
0036 bool isItemEnabled(int index) const;
0037
0038 void setItemText(int index, const QString &text);
0039 QString itemText(int index) const;
0040
0041 void setItemIcon(int index, const QIcon &icon);
0042 QIcon itemIcon(int index) const;
0043
0044 #if QT_CONFIG(tooltip)
0045 void setItemToolTip(int index, const QString &toolTip);
0046 QString itemToolTip(int index) const;
0047 #endif
0048
0049 int currentIndex() const;
0050 QWidget *currentWidget() const;
0051 QWidget *widget(int index) const;
0052 int indexOf(const QWidget *widget) const;
0053 int count() const;
0054
0055 public Q_SLOTS:
0056 void setCurrentIndex(int index);
0057 void setCurrentWidget(QWidget *widget);
0058
0059 Q_SIGNALS:
0060 void currentChanged(int index);
0061
0062 protected:
0063 bool event(QEvent *e) override;
0064 virtual void itemInserted(int index);
0065 virtual void itemRemoved(int index);
0066 void showEvent(QShowEvent *e) override;
0067 void changeEvent(QEvent *) override;
0068
0069
0070 private:
0071 Q_DECLARE_PRIVATE(QToolBox)
0072 Q_DISABLE_COPY(QToolBox)
0073 Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked())
0074 Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject*))
0075 };
0076
0077
0078 inline int QToolBox::addItem(QWidget *item, const QString &text)
0079 { return insertItem(-1, item, QIcon(), text); }
0080 inline int QToolBox::addItem(QWidget *item, const QIcon &iconSet,
0081 const QString &text)
0082 { return insertItem(-1, item, iconSet, text); }
0083 inline int QToolBox::insertItem(int index, QWidget *item, const QString &text)
0084 { return insertItem(index, item, QIcon(), text); }
0085
0086 QT_END_NAMESPACE
0087
0088 #endif