Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtabbar.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTABBAR_H
5#define QTABBAR_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qwidget.h>
9
11
13
14class QIcon;
15class QTabBarPrivate;
16class QStyleOptionTab;
17
18class Q_WIDGETS_EXPORT QTabBar: public QWidget
19{
21
22 Q_PROPERTY(Shape shape READ shape WRITE setShape)
23 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
24 Q_PROPERTY(int count READ count)
25 Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
26 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
27 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
28 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
29 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
30 Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove
31 WRITE setSelectionBehaviorOnRemove)
32 Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
33 Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
34 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
35 Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide)
36 Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag)
37
38public:
39 explicit QTabBar(QWidget *parent = nullptr);
40 ~QTabBar();
41
42 enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
43 TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
44 };
45 Q_ENUM(Shape)
46
49 RightSide
50 };
51
55 SelectPreviousTab
56 };
57
58 Shape shape() const;
59 void setShape(Shape shape);
60
61 int addTab(const QString &text);
62 int addTab(const QIcon &icon, const QString &text);
63
64 int insertTab(int index, const QString &text);
65 int insertTab(int index, const QIcon&icon, const QString &text);
66
67 void removeTab(int index);
68 void moveTab(int from, int to);
69
70 bool isTabEnabled(int index) const;
71 void setTabEnabled(int index, bool enabled);
72
73 bool isTabVisible(int index) const;
74 void setTabVisible(int index, bool visible);
75
76 QString tabText(int index) const;
77 void setTabText(int index, const QString &text);
78
79 QColor tabTextColor(int index) const;
80 void setTabTextColor(int index, const QColor &color);
81
82 QIcon tabIcon(int index) const;
83 void setTabIcon(int index, const QIcon &icon);
84
85 Qt::TextElideMode elideMode() const;
86 void setElideMode(Qt::TextElideMode mode);
87
88#if QT_CONFIG(tooltip)
89 void setTabToolTip(int index, const QString &tip);
90 QString tabToolTip(int index) const;
91#endif
92
93#if QT_CONFIG(whatsthis)
94 void setTabWhatsThis(int index, const QString &text);
95 QString tabWhatsThis(int index) const;
96#endif
97
98 void setTabData(int index, const QVariant &data);
99 QVariant tabData(int index) const;
100
101 QRect tabRect(int index) const;
102 int tabAt(const QPoint &pos) const;
103
104 int currentIndex() const;
105 int count() const;
106
107 QSize sizeHint() const override;
108 QSize minimumSizeHint() const override;
109
110 void setDrawBase(bool drawTheBase);
111 bool drawBase() const;
112
113 QSize iconSize() const;
114 void setIconSize(const QSize &size);
115
116 bool usesScrollButtons() const;
117 void setUsesScrollButtons(bool useButtons);
118
119 bool tabsClosable() const;
120 void setTabsClosable(bool closable);
121
122 void setTabButton(int index, ButtonPosition position, QWidget *widget);
123 QWidget *tabButton(int index, ButtonPosition position) const;
124
125 SelectionBehavior selectionBehaviorOnRemove() const;
126 void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
127
128 bool expanding() const;
129 void setExpanding(bool enabled);
130
131 bool isMovable() const;
132 void setMovable(bool movable);
133
134 bool documentMode() const;
135 void setDocumentMode(bool set);
136
137 bool autoHide() const;
138 void setAutoHide(bool hide);
139
140 bool changeCurrentOnDrag() const;
141 void setChangeCurrentOnDrag(bool change);
142
143#if QT_CONFIG(accessibility)
144 QString accessibleTabName(int index) const;
145 void setAccessibleTabName(int index, const QString &name);
146#endif
147
148public Q_SLOTS:
149 void setCurrentIndex(int index);
150
154 void tabMoved(int from, int to);
157
158protected:
159 virtual QSize tabSizeHint(int index) const;
160 virtual QSize minimumTabSizeHint(int index) const;
161 virtual void tabInserted(int index);
162 virtual void tabRemoved(int index);
163 virtual void tabLayoutChange();
164
165 bool event(QEvent *) override;
166 void resizeEvent(QResizeEvent *) override;
167 void showEvent(QShowEvent *) override;
168 void hideEvent(QHideEvent *) override;
169 void paintEvent(QPaintEvent *) override;
170 void mousePressEvent(QMouseEvent *) override;
171 void mouseMoveEvent(QMouseEvent *) override;
172 void mouseReleaseEvent(QMouseEvent *) override;
173 void mouseDoubleClickEvent(QMouseEvent *) override;
174#if QT_CONFIG(wheelevent)
175 void wheelEvent(QWheelEvent *event) override;
176#endif
177 void keyPressEvent(QKeyEvent *) override;
178 void changeEvent(QEvent *) override;
179 void timerEvent(QTimerEvent *event) override;
180 virtual void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
181
182#if QT_CONFIG(accessibility)
183 friend class QAccessibleTabBar;
184#endif
185private:
186 Q_DISABLE_COPY(QTabBar)
187 Q_DECLARE_PRIVATE(QTabBar)
188 Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
189 Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
190};
191
193
194#endif // QTABBAR_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qcoreevent.h:45
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:585
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:423
\inmodule QtGui
Definition qevent.h:195
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1433
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:547
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:577
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QTabBar class provides a tab bar, e.g.
Definition qtabbar.h:19
ButtonPosition
Definition qtabbar.h:47
@ LeftSide
Definition qtabbar.h:48
void currentChanged(int index)
This signal is emitted when the tab bar's current tab changes.
void tabBarDoubleClicked(int index)
This signal is emitted when the user double clicks on a tab at index.
void tabCloseRequested(int index)
void tabMoved(int from, int to)
SelectionBehavior
Definition qtabbar.h:52
@ SelectLeftTab
Definition qtabbar.h:53
@ SelectRightTab
Definition qtabbar.h:54
void tabBarClicked(int index)
This signal is emitted when user clicks on a tab at an index.
Shape
This enum type lists the built-in shapes supported by QTabBar.
Definition qtabbar.h:42
@ RoundedEast
Definition qtabbar.h:42
@ TriangularNorth
Definition qtabbar.h:43
\inmodule QtCore
Definition qcoreevent.h:359
\inmodule QtCore
Definition qvariant.h:64
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
virtual void hideEvent(QHideEvent *event)
This event handler can be reimplemented in a subclass to receive widget hide events.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition qwidget.cpp:9507
virtual void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition qwidget.cpp:9529
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
Definition qwidget.cpp:9576
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition qwidget.cpp:9554
QSize minimumSizeHint
the recommended minimum size for the widget
Definition qwidget.h:149
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9428
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
virtual void resizeEvent(QResizeEvent *event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qwidget.cpp:9868
virtual void keyPressEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition qwidget.cpp:9652
virtual void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwidget.cpp:9829
virtual void showEvent(QShowEvent *event)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
QOpenGLWidget * widget
[1]
QString text
opt iconSize
Combined button and popup list for selecting options.
TextElideMode
Definition qnamespace.h:187
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
struct _cl_event * event
GLuint GLenum option
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define QT_REQUIRE_CONFIG(feature)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QFuture< QSet< QChar > > set
[10]
edit hide()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent