- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtabbar.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTABBAR_H
    00043 #define QTABBAR_H
    00044
    00045 #include <QtGui/qwidget.h>
    00046
    00047 QT_BEGIN_HEADER
    00048
    00049 QT_BEGIN_NAMESPACE
    00050
    00051 QT_MODULE(Gui)
    00052
    00053 #ifndef QT_NO_TABBAR
    00054
    00055 class QIcon;
    00056 class QTabBarPrivate;
    00057 class QStyleOptionTab;
    00058
    00059 class Q_GUI_EXPORT QTabBar: public QWidget
    00060 {
    00061     Q_OBJECT
    00062
    00063     Q_ENUMS(Shape)
    00064     Q_PROPERTY(Shape shape READ shape WRITE setShape)
    00065     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
    00066     Q_PROPERTY(int count READ count)
    00067     Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
    00068     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
    00069     Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
    00070     Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
    00071     Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
    00072     Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove)
    00073     Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
    00074     Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
    00075     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
    00076
    00077 public:
    00078     explicit QTabBar(QWidget* parent=0);
    00079     ~QTabBar();
    00080
    00081     enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
    00082                  TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
    00083 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
    00084                 , RoundedAbove = RoundedNorth, RoundedBelow = RoundedSouth,
    00085                 TriangularAbove = TriangularNorth, TriangularBelow = TriangularSouth
    00086 #endif
    00087     };
    00088
    00089     enum ButtonPosition {
    00090         LeftSide,
    00091         RightSide
    00092     };
    00093
    00094     enum SelectionBehavior {
    00095         SelectLeftTab,
    00096         SelectRightTab,
    00097         SelectPreviousTab
    00098     };
    00099
    00100     Shape shape() const;
    00101     void setShape(Shape shape);
    00102
    00103     int addTab(const QString &text);
    00104     int addTab(const QIcon &icon, const QString &text);
    00105
    00106     int insertTab(int index, const QString &text);
    00107     int insertTab(int index, const QIcon&icon, const QString &text);
    00108
    00109     void removeTab(int index);
    00110     void moveTab(int from, int to);
    00111
    00112     bool isTabEnabled(int index) const;
    00113     void setTabEnabled(int index, bool);
    00114
    00115     QString tabText(int index) const;
    00116     void setTabText(int index, const QString &text);
    00117
    00118     QColor tabTextColor(int index) const;
    00119     void setTabTextColor(int index, const QColor &color);
    00120
    00121     QIcon tabIcon(int index) const;
    00122     void setTabIcon(int index, const QIcon &icon);
    00123
    00124     Qt::TextElideMode elideMode() const;
    00125     void setElideMode(Qt::TextElideMode);
    00126
    00127 #ifndef QT_NO_TOOLTIP
    00128     void setTabToolTip(int index, const QString &tip);
    00129     QString tabToolTip(int index) const;
    00130 #endif
    00131
    00132 #ifndef QT_NO_WHATSTHIS
    00133     void setTabWhatsThis(int index, const QString &text);
    00134     QString tabWhatsThis(int index) const;
    00135 #endif
    00136
    00137     void setTabData(int index, const QVariant &data);
    00138     QVariant tabData(int index) const;
    00139
    00140     QRect tabRect(int index) const;
    00141     int tabAt(const QPoint &pos) const;
    00142
    00143     int currentIndex() const;
    00144     int count() const;
    00145
    00146     QSize sizeHint() const;
    00147     QSize minimumSizeHint() const;
    00148
    00149     void setDrawBase(bool drawTheBase);
    00150     bool drawBase() const;
    00151
    00152     QSize iconSize() const;
    00153     void setIconSize(const QSize &size);
    00154
    00155     bool usesScrollButtons() const;
    00156     void setUsesScrollButtons(bool useButtons);
    00157
    00158     bool tabsClosable() const;
    00159     void setTabsClosable(bool closable);
    00160
    00161     void setTabButton(int index, ButtonPosition position, QWidget *widget);
    00162     QWidget *tabButton(int index, ButtonPosition position) const;
    00163
    00164     SelectionBehavior selectionBehaviorOnRemove() const;
    00165     void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
    00166
    00167     bool expanding() const;
    00168     void setExpanding(bool enabled);
    00169
    00170     bool isMovable() const;
    00171     void setMovable(bool movable);
    00172
    00173     bool documentMode() const;
    00174     void setDocumentMode(bool set);
    00175
    00176 public Q_SLOTS:
    00177     void setCurrentIndex(int index);
    00178
    00179 Q_SIGNALS:
    00180     void currentChanged(int index);
    00181     void tabCloseRequested(int index);
    00182     void tabMoved(int from, int to);
    00183
    00184 protected:
    00185     virtual QSize tabSizeHint(int index) const;
    00186     virtual void tabInserted(int index);
    00187     virtual void tabRemoved(int index);
    00188     virtual void tabLayoutChange();
    00189
    00190     bool event(QEvent *);
    00191     void resizeEvent(QResizeEvent *);
    00192     void showEvent(QShowEvent *);
    00193     void hideEvent(QHideEvent *);
    00194     void paintEvent(QPaintEvent *);
    00195     void mousePressEvent (QMouseEvent *);
    00196     void mouseMoveEvent (QMouseEvent *);
    00197     void mouseReleaseEvent (QMouseEvent *);
    00198 #ifndef QT_NO_WHEELEVENT
    00199     void wheelEvent(QWheelEvent *event);
    00200 #endif
    00201     void keyPressEvent(QKeyEvent *);
    00202     void changeEvent(QEvent *);
    00203     void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
    00204
    00205 #ifdef QT3_SUPPORT
    00206 public Q_SLOTS:
    00207     QT_MOC_COMPAT void setCurrentTab(int index) { setCurrentIndex(index); }
    00208 Q_SIGNALS:
    00209     QT_MOC_COMPAT void selected(int);
    00210 #endif
    00211
    00212     friend class QAccessibleTabBar;
    00213 private:
    00214     Q_DISABLE_COPY(QTabBar)
    00215     Q_DECLARE_PRIVATE(QTabBar)
    00216     Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
    00217     Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
    00218 };
    00219
    00220 #endif // QT_NO_TABBAR
    00221
    00222 QT_END_NAMESPACE
    00223
    00224 QT_END_HEADER
    00225
    00226 #endif // QTABBAR_H