QtBase  v6.3.1
qtabbar.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTABBAR_H
41 #define QTABBAR_H
42 
43 #include <QtWidgets/qtwidgetsglobal.h>
44 #include <QtWidgets/qwidget.h>
45 
47 
49 
50 class QIcon;
51 class QTabBarPrivate;
52 class QStyleOptionTab;
53 
54 class Q_WIDGETS_EXPORT QTabBar: public QWidget
55 {
56  Q_OBJECT
57 
58  Q_PROPERTY(Shape shape READ shape WRITE setShape)
59  Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
60  Q_PROPERTY(int count READ count)
61  Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
62  Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
63  Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
64  Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
65  Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
66  Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove
67  WRITE setSelectionBehaviorOnRemove)
68  Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
69  Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
70  Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
71  Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide)
72  Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag)
73 
74 public:
75  explicit QTabBar(QWidget *parent = nullptr);
76  ~QTabBar();
77 
78  enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
79  TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
80  };
81  Q_ENUM(Shape)
82 
85  RightSide
86  };
87 
91  SelectPreviousTab
92  };
93 
94  Shape shape() const;
95  void setShape(Shape shape);
96 
97  int addTab(const QString &text);
98  int addTab(const QIcon &icon, const QString &text);
99 
100  int insertTab(int index, const QString &text);
101  int insertTab(int index, const QIcon&icon, const QString &text);
102 
103  void removeTab(int index);
104  void moveTab(int from, int to);
105 
106  bool isTabEnabled(int index) const;
107  void setTabEnabled(int index, bool enabled);
108 
109  bool isTabVisible(int index) const;
110  void setTabVisible(int index, bool visible);
111 
112  QString tabText(int index) const;
113  void setTabText(int index, const QString &text);
114 
115  QColor tabTextColor(int index) const;
116  void setTabTextColor(int index, const QColor &color);
117 
118  QIcon tabIcon(int index) const;
119  void setTabIcon(int index, const QIcon &icon);
120 
121  Qt::TextElideMode elideMode() const;
122  void setElideMode(Qt::TextElideMode mode);
123 
124 #if QT_CONFIG(tooltip)
125  void setTabToolTip(int index, const QString &tip);
126  QString tabToolTip(int index) const;
127 #endif
128 
129 #if QT_CONFIG(whatsthis)
130  void setTabWhatsThis(int index, const QString &text);
131  QString tabWhatsThis(int index) const;
132 #endif
133 
134  void setTabData(int index, const QVariant &data);
135  QVariant tabData(int index) const;
136 
137  QRect tabRect(int index) const;
138  int tabAt(const QPoint &pos) const;
139 
140  int currentIndex() const;
141  int count() const;
142 
143  QSize sizeHint() const override;
144  QSize minimumSizeHint() const override;
145 
146  void setDrawBase(bool drawTheBase);
147  bool drawBase() const;
148 
149  QSize iconSize() const;
150  void setIconSize(const QSize &size);
151 
152  bool usesScrollButtons() const;
153  void setUsesScrollButtons(bool useButtons);
154 
155  bool tabsClosable() const;
156  void setTabsClosable(bool closable);
157 
158  void setTabButton(int index, ButtonPosition position, QWidget *widget);
159  QWidget *tabButton(int index, ButtonPosition position) const;
160 
161  SelectionBehavior selectionBehaviorOnRemove() const;
162  void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
163 
164  bool expanding() const;
165  void setExpanding(bool enabled);
166 
167  bool isMovable() const;
168  void setMovable(bool movable);
169 
170  bool documentMode() const;
171  void setDocumentMode(bool set);
172 
173  bool autoHide() const;
174  void setAutoHide(bool hide);
175 
176  bool changeCurrentOnDrag() const;
177  void setChangeCurrentOnDrag(bool change);
178 
179 #ifndef QT_NO_ACCESSIBILITY
180  QString accessibleTabName(int index) const;
181  void setAccessibleTabName(int index, const QString &name);
182 #endif
183 
184 public Q_SLOTS:
185  void setCurrentIndex(int index);
186 
187 Q_SIGNALS:
190  void tabMoved(int from, int to);
191  void tabBarClicked(int index);
193 
194 protected:
195  virtual QSize tabSizeHint(int index) const;
196  virtual QSize minimumTabSizeHint(int index) const;
197  virtual void tabInserted(int index);
198  virtual void tabRemoved(int index);
199  virtual void tabLayoutChange();
200 
201  bool event(QEvent *) override;
202  void resizeEvent(QResizeEvent *) override;
203  void showEvent(QShowEvent *) override;
204  void hideEvent(QHideEvent *) override;
205  void paintEvent(QPaintEvent *) override;
206  void mousePressEvent(QMouseEvent *) override;
207  void mouseMoveEvent(QMouseEvent *) override;
208  void mouseReleaseEvent(QMouseEvent *) override;
209  void mouseDoubleClickEvent(QMouseEvent *) override;
210 #if QT_CONFIG(wheelevent)
211  void wheelEvent(QWheelEvent *event) override;
212 #endif
213  void keyPressEvent(QKeyEvent *) override;
214  void changeEvent(QEvent *) override;
215  void timerEvent(QTimerEvent *event) override;
216  virtual void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
217 
218 #ifndef QT_NO_ACCESSIBILITY
219  friend class QAccessibleTabBar;
220 #endif
221 private:
223  Q_DECLARE_PRIVATE(QTabBar)
224  Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
225  Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
226 };
227 
229 
230 #endif // QTABBAR_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:656
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:56
The QKeyEvent class describes a key event.
Definition: qevent.h:471
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:231
virtual void timerEvent(QTimerEvent *event)
Definition: qobject.cpp:1399
The QPaintEvent class contains event parameters for paint events. \inmodule QtGui.
Definition: qevent.h:539
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
Definition: qevent.h:612
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:647
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.
Definition: qtabbar.h:55
ButtonPosition
Definition: qtabbar.h:83
@ LeftSide
Definition: qtabbar.h:84
void currentChanged(int index)
void tabBarDoubleClicked(int index)
void tabCloseRequested(int index)
void tabMoved(int from, int to)
SelectionBehavior
Definition: qtabbar.h:88
@ SelectLeftTab
Definition: qtabbar.h:89
@ SelectRightTab
Definition: qtabbar.h:90
void tabBarClicked(int index)
@ RoundedEast
Definition: qtabbar.h:78
@ TriangularNorth
Definition: qtabbar.h:79
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:367
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
virtual void hideEvent(QHideEvent *event)
Definition: qwidget.cpp:10004
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: qwidget.cpp:9362
virtual void mousePressEvent(QMouseEvent *event)
Definition: qwidget.cpp:9384
virtual void mouseDoubleClickEvent(QMouseEvent *event)
Definition: qwidget.cpp:9431
virtual void mouseReleaseEvent(QMouseEvent *event)
Definition: qwidget.cpp:9409
QSize minimumSizeHint
the recommended minimum size for the widget
Definition: qwidget.h:183
virtual void changeEvent(QEvent *)
Definition: qwidget.cpp:9283
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:182
bool event(QEvent *event) override
Definition: qwidget.cpp:8772
virtual void resizeEvent(QResizeEvent *event)
Definition: qwidget.cpp:9723
virtual void keyPressEvent(QKeyEvent *event)
Definition: qwidget.cpp:9507
virtual void paintEvent(QPaintEvent *event)
Definition: qwidget.cpp:9684
virtual void showEvent(QShowEvent *event)
Definition: qwidget.cpp:9982
Definition: document.h:60
QOpenGLWidget * widget
[1]
opt iconSize
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
TextElideMode
Definition: qnamespace.h:213
#define Q_DISABLE_COPY(Class)
Definition: qglobal.h:515
@ text
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint color
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
struct _cl_event * event
Definition: qopenglext.h:2998
GLuint GLenum option
Definition: qopenglext.h:5929
QT_REQUIRE_CONFIG(tabbar)
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_SLOTS
Definition: qtmetamacros.h:80
#define Q_PRIVATE_SLOT(d, signature)
Definition: qtmetamacros.h:82
#define Q_SIGNALS
Definition: qtmetamacros.h:81
QFuture< QSet< QChar > > set
[10]
QIcon icon
[15]
edit hide()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent