Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtabwidget.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 QTABWIDGET_H
5#define QTABWIDGET_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qwidget.h>
9#include <QtGui/qicon.h>
10
12
14
15class QTabBar;
17class QStyleOptionTabWidgetFrame;
18
19class Q_WIDGETS_EXPORT QTabWidget : public QWidget
20{
22 Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
23 Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
24 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
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 documentMode READ documentMode WRITE setDocumentMode)
30 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
31 Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
32 Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide)
33
34public:
35 explicit QTabWidget(QWidget *parent = nullptr);
36 ~QTabWidget();
37
38 int addTab(QWidget *widget, const QString &);
39 int addTab(QWidget *widget, const QIcon& icon, const QString &label);
40
41 int insertTab(int index, QWidget *widget, const QString &);
42 int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
43
44 void removeTab(int index);
45
46 bool isTabEnabled(int index) const;
47 void setTabEnabled(int index, bool enabled);
48
49 bool isTabVisible(int index) const;
50 void setTabVisible(int index, bool visible);
51
52 QString tabText(int index) const;
53 void setTabText(int index, const QString &text);
54
55 QIcon tabIcon(int index) const;
56 void setTabIcon(int index, const QIcon & icon);
57
58#if QT_CONFIG(tooltip)
59 void setTabToolTip(int index, const QString & tip);
60 QString tabToolTip(int index) const;
61#endif
62
63#if QT_CONFIG(whatsthis)
64 void setTabWhatsThis(int index, const QString &text);
65 QString tabWhatsThis(int index) const;
66#endif
67
68 int currentIndex() const;
69 QWidget *currentWidget() const;
70 QWidget *widget(int index) const;
71 int indexOf(const QWidget *widget) const;
72 int count() const;
73
74 enum TabPosition { North, South, West, East };
75 Q_ENUM(TabPosition)
76 TabPosition tabPosition() const;
77 void setTabPosition(TabPosition position);
78
79 bool tabsClosable() const;
80 void setTabsClosable(bool closeable);
81
82 bool isMovable() const;
83 void setMovable(bool movable);
84
85 enum TabShape { Rounded, Triangular };
86 Q_ENUM(TabShape)
87 TabShape tabShape() const;
88 void setTabShape(TabShape s);
89
90 QSize sizeHint() const override;
91 QSize minimumSizeHint() const override;
92 int heightForWidth(int width) const override;
93 bool hasHeightForWidth() const override;
94
95 void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
96 QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
97
98 Qt::TextElideMode elideMode() const;
99 void setElideMode(Qt::TextElideMode mode);
100
101 QSize iconSize() const;
102 void setIconSize(const QSize &size);
103
104 bool usesScrollButtons() const;
105 void setUsesScrollButtons(bool useButtons);
106
107 bool documentMode() const;
108 void setDocumentMode(bool set);
109
110 bool tabBarAutoHide() const;
111 void setTabBarAutoHide(bool enabled);
112
113 void clear();
114
115 QTabBar* tabBar() const;
116
117public Q_SLOTS:
118 void setCurrentIndex(int index);
119 void setCurrentWidget(QWidget *widget);
120
126
127protected:
128 virtual void tabInserted(int index);
129 virtual void tabRemoved(int index);
130
131 void showEvent(QShowEvent *) override;
132 void resizeEvent(QResizeEvent *) override;
133 void keyPressEvent(QKeyEvent *) override;
134 void paintEvent(QPaintEvent *) override;
135 void setTabBar(QTabBar *);
136 void changeEvent(QEvent *) override;
137 bool event(QEvent *) override;
138 virtual void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
139
140
141private:
142 Q_DECLARE_PRIVATE(QTabWidget)
143 Q_DISABLE_COPY(QTabWidget)
144 void setUpLayout(bool = false);
145};
146
148
149#endif // QTABWIDGET_H
\inmodule QtCore
Definition qcoreevent.h:45
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:424
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTabBar class provides a tab bar, e.g.
Definition qtabbar.h:19
The QTabWidget class provides a stack of tabbed widgets.
Definition qtabwidget.h:20
TabPosition
This enum type defines where QTabWidget draws the tab row:
Definition qtabwidget.h:74
void currentChanged(int index)
This signal is emitted whenever the current page index changes.
void tabBarDoubleClicked(int index)
This signal is emitted when the user double clicks on a tab at an index.
void tabBarClicked(int index)
This signal is emitted when user clicks on a tab at an index.
void tabCloseRequested(int index)
TabShape
This enum type defines the shape of the tabs: \value Rounded The tabs are drawn with a rounded look.
Definition qtabwidget.h:85
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
b clear()
QString text
opt iconSize
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ TopRightCorner
TextElideMode
Definition qnamespace.h:188
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei width
GLuint GLsizei const GLchar * label
[43]
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
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_SIGNALS
#define explicit
QFuture< QSet< QChar > > set
[10]
list indexOf("B")