Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:39

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