Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-01 09:24:05

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QTABWIDGET_H
0006 #define QTABWIDGET_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qwidget.h>
0010 #include <QtGui/qicon.h>
0011 
0012 QT_REQUIRE_CONFIG(tabwidget);
0013 
0014 QT_BEGIN_NAMESPACE
0015 
0016 class QTabBar;
0017 class QTabWidgetPrivate;
0018 class QStyleOptionTabWidgetFrame;
0019 
0020 class Q_WIDGETS_EXPORT QTabWidget : public QWidget
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
0024     Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
0025     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
0026     Q_PROPERTY(int count READ count)
0027     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
0028     Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
0029     Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
0030     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
0031     Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
0032     Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
0033     Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide)
0034 
0035 public:
0036     explicit QTabWidget(QWidget *parent = nullptr);
0037     ~QTabWidget();
0038 
0039     int addTab(QWidget *widget, const QString &);
0040     int addTab(QWidget *widget, const QIcon& icon, const QString &label);
0041 
0042     int insertTab(int index, QWidget *widget, const QString &);
0043     int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
0044 
0045     void removeTab(int index);
0046 
0047     bool isTabEnabled(int index) const;
0048     void setTabEnabled(int index, bool enabled);
0049 
0050     bool isTabVisible(int index) const;
0051     void setTabVisible(int index, bool visible);
0052 
0053     QString tabText(int index) const;
0054     void setTabText(int index, const QString &text);
0055 
0056     QIcon tabIcon(int index) const;
0057     void setTabIcon(int index, const QIcon & icon);
0058 
0059 #if QT_CONFIG(tooltip)
0060     void setTabToolTip(int index, const QString & tip);
0061     QString tabToolTip(int index) const;
0062 #endif
0063 
0064 #if QT_CONFIG(whatsthis)
0065     void setTabWhatsThis(int index, const QString &text);
0066     QString tabWhatsThis(int index) const;
0067 #endif
0068 
0069     int currentIndex() const;
0070     QWidget *currentWidget() const;
0071     QWidget *widget(int index) const;
0072     int indexOf(const QWidget *widget) const;
0073     int count() const;
0074 
0075     enum TabPosition { North, South, West, East };
0076     Q_ENUM(TabPosition)
0077     TabPosition tabPosition() const;
0078     void setTabPosition(TabPosition position);
0079 
0080     bool tabsClosable() const;
0081     void setTabsClosable(bool closeable);
0082 
0083     bool isMovable() const;
0084     void setMovable(bool movable);
0085 
0086     enum TabShape { Rounded, Triangular };
0087     Q_ENUM(TabShape)
0088     TabShape tabShape() const;
0089     void setTabShape(TabShape s);
0090 
0091     QSize sizeHint() const override;
0092     QSize minimumSizeHint() const override;
0093     int heightForWidth(int width) const override;
0094     bool hasHeightForWidth() const override;
0095 
0096     void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
0097     QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
0098 
0099     Qt::TextElideMode elideMode() const;
0100     void setElideMode(Qt::TextElideMode mode);
0101 
0102     QSize iconSize() const;
0103     void setIconSize(const QSize &size);
0104 
0105     bool usesScrollButtons() const;
0106     void setUsesScrollButtons(bool useButtons);
0107 
0108     bool documentMode() const;
0109     void setDocumentMode(bool set);
0110 
0111     bool tabBarAutoHide() const;
0112     void setTabBarAutoHide(bool enabled);
0113 
0114     void clear();
0115 
0116     QTabBar* tabBar() const;
0117 
0118 public Q_SLOTS:
0119     void setCurrentIndex(int index);
0120     void setCurrentWidget(QWidget *widget);
0121 
0122 Q_SIGNALS:
0123     void currentChanged(int index);
0124     void tabCloseRequested(int index);
0125     void tabBarClicked(int index);
0126     void tabBarDoubleClicked(int index);
0127 
0128 protected:
0129     virtual void tabInserted(int index);
0130     virtual void tabRemoved(int index);
0131 
0132     void showEvent(QShowEvent *) override;
0133     void resizeEvent(QResizeEvent *) override;
0134     void keyPressEvent(QKeyEvent *) override;
0135     void paintEvent(QPaintEvent *) override;
0136     void setTabBar(QTabBar *);
0137     void changeEvent(QEvent *) override;
0138     bool event(QEvent *) override;
0139     virtual void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
0140 
0141 
0142 private:
0143     Q_DECLARE_PRIVATE(QTabWidget)
0144     Q_DISABLE_COPY(QTabWidget)
0145     void setUpLayout(bool = false);
0146 };
0147 
0148 QT_END_NAMESPACE
0149 
0150 #endif // QTABWIDGET_H