Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTOOLBOX_H
00043 #define QTOOLBOX_H
00044
00045 #include <QtGui/qframe.h>
00046 #include <QtGui/qicon.h>
00047
00048 QT_BEGIN_HEADER
00049
00050 QT_BEGIN_NAMESPACE
00051
00052 QT_MODULE(Gui)
00053
00054 #ifndef QT_NO_TOOLBOX
00055
00056 class QToolBoxPrivate;
00057
00058 class Q_GUI_EXPORT QToolBox : public QFrame
00059 {
00060 Q_OBJECT
00061 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
00062 Q_PROPERTY(int count READ count)
00063
00064 public:
00065 explicit QToolBox(QWidget *parent = 0, Qt::WindowFlags f = 0);
00066 ~QToolBox();
00067
00068 int addItem(QWidget *widget, const QString &text);
00069 int addItem(QWidget *widget, const QIcon &icon, const QString &text);
00070 int insertItem(int index, QWidget *widget, const QString &text);
00071 int insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text);
00072
00073 void removeItem(int index);
00074
00075 void setItemEnabled(int index, bool enabled);
00076 bool isItemEnabled(int index) const;
00077
00078 void setItemText(int index, const QString &text);
00079 QString itemText(int index) const;
00080
00081 void setItemIcon(int index, const QIcon &icon);
00082 QIcon itemIcon(int index) const;
00083
00084 #ifndef QT_NO_TOOLTIP
00085 void setItemToolTip(int index, const QString &toolTip);
00086 QString itemToolTip(int index) const;
00087 #endif
00088
00089 int currentIndex() const;
00090 QWidget *currentWidget() const;
00091 QWidget *widget(int index) const;
00092 int indexOf(QWidget *widget) const;
00093 int count() const;
00094
00095 public Q_SLOTS:
00096 void setCurrentIndex(int index);
00097 void setCurrentWidget(QWidget *widget);
00098
00099 Q_SIGNALS:
00100 void currentChanged(int index);
00101
00102 protected:
00103 bool event(QEvent *e);
00104 virtual void itemInserted(int index);
00105 virtual void itemRemoved(int index);
00106 void showEvent(QShowEvent *e);
00107 void changeEvent(QEvent *);
00108
00109 #ifdef QT3_SUPPORT
00110 public:
00111 QT3_SUPPORT_CONSTRUCTOR QToolBox(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
00112 inline QT3_SUPPORT void setItemLabel(int index, const QString &text) { setItemText(index, text); }
00113 inline QT3_SUPPORT QString itemLabel(int index) const { return itemText(index); }
00114 inline QT3_SUPPORT QWidget *currentItem() const { return widget(currentIndex()); }
00115 inline QT3_SUPPORT void setCurrentItem(QWidget *item) { setCurrentIndex(indexOf(item)); }
00116 inline QT3_SUPPORT void setItemIconSet(int index, const QIcon &icon) { setItemIcon(index, icon); }
00117 inline QT3_SUPPORT QIcon itemIconSet(int index) const { return itemIcon(index); }
00118 inline QT3_SUPPORT int removeItem(QWidget *item)
00119 { int i = indexOf(item); removeItem(i); return i; }
00120 inline QT3_SUPPORT QWidget *item(int index) const { return widget(index); }
00121 QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
00122 QT3_SUPPORT int margin() const
00123 { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
00124 #endif
00125
00126 private:
00127 Q_DECLARE_PRIVATE(QToolBox)
00128 Q_DISABLE_COPY(QToolBox)
00129 Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked())
00130 Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject*))
00131 };
00132
00133
00134 inline int QToolBox::addItem(QWidget *item, const QString &text)
00135 { return insertItem(-1, item, QIcon(), text); }
00136 inline int QToolBox::addItem(QWidget *item, const QIcon &iconSet,
00137 const QString &text)
00138 { return insertItem(-1, item, iconSet, text); }
00139 inline int QToolBox::insertItem(int index, QWidget *item, const QString &text)
00140 { return insertItem(index, item, QIcon(), text); }
00141
00142 #endif // QT_NO_TOOLBOX
00143
00144 QT_END_NAMESPACE
00145
00146 QT_END_HEADER
00147
00148 #endif // QTOOLBOX_H