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 QABSTRACTBUTTON_H
00043 #define QABSTRACTBUTTON_H
00044
00045 #include <QtGui/qicon.h>
00046 #include <QtGui/qkeysequence.h>
00047 #include <QtGui/qwidget.h>
00048
00049 QT_BEGIN_HEADER
00050
00051 QT_BEGIN_NAMESPACE
00052
00053 QT_MODULE(Gui)
00054
00055 class QButtonGroup;
00056 class QAbstractButtonPrivate;
00057
00058 class Q_GUI_EXPORT QAbstractButton : public QWidget
00059 {
00060 Q_OBJECT
00061
00062 Q_PROPERTY(QString text READ text WRITE setText)
00063 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
00064 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
00065 #ifndef QT_NO_SHORTCUT
00066 Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
00067 #endif
00068 Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
00069 Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
00070 Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
00071 Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
00072 Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
00073 Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval)
00074 Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
00075
00076 public:
00077 explicit QAbstractButton(QWidget* parent=0);
00078 ~QAbstractButton();
00079
00080 void setText(const QString &text);
00081 QString text() const;
00082
00083 void setIcon(const QIcon &icon);
00084 QIcon icon() const;
00085
00086 QSize iconSize() const;
00087
00088 #ifndef QT_NO_SHORTCUT
00089 void setShortcut(const QKeySequence &key);
00090 QKeySequence shortcut() const;
00091 #endif
00092
00093 void setCheckable(bool);
00094 bool isCheckable() const;
00095
00096 bool isChecked() const;
00097
00098 void setDown(bool);
00099 bool isDown() const;
00100
00101 void setAutoRepeat(bool);
00102 bool autoRepeat() const;
00103
00104 void setAutoRepeatDelay(int);
00105 int autoRepeatDelay() const;
00106
00107 void setAutoRepeatInterval(int);
00108 int autoRepeatInterval() const;
00109
00110 void setAutoExclusive(bool);
00111 bool autoExclusive() const;
00112
00113 #ifndef QT_NO_BUTTONGROUP
00114 QButtonGroup *group() const;
00115 #endif
00116
00117 public Q_SLOTS:
00118 void setIconSize(const QSize &size);
00119 void animateClick(int msec = 100);
00120 void click();
00121 void toggle();
00122 void setChecked(bool);
00123
00124 Q_SIGNALS:
00125 void pressed();
00126 void released();
00127 void clicked(bool checked = false);
00128 void toggled(bool checked);
00129
00130 protected:
00131 virtual void paintEvent(QPaintEvent *e) = 0;
00132 virtual bool hitButton(const QPoint &pos) const;
00133 virtual void checkStateSet();
00134 virtual void nextCheckState();
00135
00136 bool event(QEvent *e);
00137 void keyPressEvent(QKeyEvent *e);
00138 void keyReleaseEvent(QKeyEvent *e);
00139 void mousePressEvent(QMouseEvent *e);
00140 void mouseReleaseEvent(QMouseEvent *e);
00141 void mouseMoveEvent(QMouseEvent *e);
00142 void focusInEvent(QFocusEvent *e);
00143 void focusOutEvent(QFocusEvent *e);
00144 void changeEvent(QEvent *e);
00145 void timerEvent(QTimerEvent *e);
00146
00147 #ifdef QT3_SUPPORT
00148 public:
00149 QT3_SUPPORT_CONSTRUCTOR QAbstractButton(QWidget *parent, const char *name, Qt::WindowFlags f=0);
00150 inline QT3_SUPPORT bool isOn() const { return isChecked(); }
00151 inline QT3_SUPPORT const QPixmap *pixmap() const { return 0; }
00152 inline QT3_SUPPORT void setPixmap( const QPixmap &p ) {
00153 setIcon(QIcon(p));
00154 setIconSize(p.size());
00155 }
00156 QT3_SUPPORT QIcon *iconSet() const;
00157 inline QT3_SUPPORT void setIconSet(const QIcon &icon) { setIcon(icon); }
00158 inline QT3_SUPPORT bool isToggleButton() const { return isCheckable(); }
00159 inline QT3_SUPPORT void setToggleButton(bool b) { setCheckable(b); }
00160 inline QT3_SUPPORT void setAccel(const QKeySequence &key) { setShortcut(key); }
00161 inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
00162
00163 public Q_SLOTS:
00164 inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
00165 #endif
00166
00167 protected:
00168 QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
00169
00170 private:
00171 Q_DECLARE_PRIVATE(QAbstractButton)
00172 Q_DISABLE_COPY(QAbstractButton)
00173 friend class QButtonGroup;
00174 };
00175
00176 QT_END_NAMESPACE
00177
00178 QT_END_HEADER
00179
00180 #endif // QABSTRACTBUTTON_H